Updating and Deleting Records

AutoCAD Map 3D .NET API

 
Updating and Deleting Records
 
 
 

To update or delete records, they must be opened for write access in the call to Table.GetObjectTableRecords() or Tables.GetObjectRecords().

Fields in a record are of type Utilities.MapValue. To update a field, get a reference to the value from the Record object. Assign a new value using MapValue.Assign() and update the record using Records.UpdateRecord(). The following example sets the value of the first field in a record:

Dim val As Utilities.MapValue = rec(0)
val.Assign(19)
recs.UpdateRecord(rec)

To delete a record, get an IEnumerator using Records.GetEnumerator(). Advance the enumerator to the record to be deleted and call Records.RemoveRecord(). The following example deletes the first record for an object.

Dim recs As ObjectData.Records
recs = table.GetObjectTableRecords(0, objId, _
  Constants.OpenMode.OpenForWrite, True)
 
Dim ie As IEnumerator
ie = recs.GetEnumerator()
ie.MoveNext()
recs.RemoveRecord()
recs.Dispose()