Initializes an ODRecords collection with the records of a given drawing object.
Init( _
acadObject As Object, _
OpenMode As Boolean, _
SkipNested As Boolean _
) As Boolean
Returns True on success.
acadObject
OpenMode
SkipNested
You can instantiate an ODRecords collection by calling either ODTable.GetODRecords() or ODTables.GetODREcords(). In the first case, you are referencing a particular object-data table definition. In the second, you are referencing all object-data table definitions in the project. When you initialize the ODRecords collection in the first case, you initialize it with all the records attached to the given object that match a particular table definition. When you initialize the ODRecords collection in the second case, you in itialize it with all the records attached to the given object that match any table definition.
Note You must explicitly release an ODRecords collection when you are finished with it.
The following sample demonstrates reading and editing existing records. The ODRecords collection is created before we enter the loop, and it is not released until we exit the loop, because each call to Init() reuses the same collection object. The sample assumes a selection set, ss, and an object-data table, oTable2.
Set oRecords = oTable2.GetODRecords() Dim oDrawingObject As AcadEntity Dim bRetVal As Boolean For Each oDrawingObject In ss bRetVal = oRecords.Init(oDrawingObject, True, True) While oRecords.IsDone = False oRecord.Item(1).Value = oRecord.Item(0).Value oRecords.Next Wend Next Set oRecords = Nothing
Note Although you can read or edit records, you cannot add or remove records during the life of an ODRecords object.
The following sample demonstrates iterating existing records and then adding records based on what we have found. In this situation, the ODRecords collection is created within the loop and then released within the loop before any records are added. The sample assumes a selection set, ss, and an object-data table, oTable2.
Dim oDrawingObject As AcadEntity Dim bRetVal As Boolean Dim bHasRecords As Boolean Dim oRecord As ODRecord For Each oDrawingObject In ss bHasRecords = False Set oRecords = oTable2.GetODRecords() bRetVal = oRecords.Init(oDrawingObject, True, True) While oRecords.IsDone = False HasRecords = True oRecords.Next Wend Set oRecords = Nothing If HasRecords = False Then Set oRecord = oTable2.CreateRecord oRecord.Item(0).Value = "0" bRetVal = oRecord.AttachTo(CLng(oDrawingObject.ObjectID)) End If Next Set oRecord = Nothing