Message 1 of 3
Editing ODTables with VBA

Not applicable
12-10-2003
01:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a drawing on wich the objects have several ODTables atached to.
I am trying to, for each object, scan the contents of one ODTable, and then
change the records on another ODTable.
The chosen way is to create 2 diferent ODRecords for the same object at the
time. The first one is for scaning the data in the first table (openmode
false), and the other for updating the second table (openmode true).
I made this code:
............................................................................
...
Dim amap As AcadMap
Set amap =
ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application.2")
'ODRecords from ODTable1
Dim odRecordsCxT As odRecords
Set odRecordsCxT =
amap.Projects(ThisDrawing).ODTables.Item(ODtable1_name).GetODRecords
'ODRecords from ODTable2
Dim odRecordsCx As odRecords
Set odRecordsCx =
amap.Projects(ThisDrawing).ODTables.Item(ODTable2_name).GetODRecords
Dim obj As AcadObject
For Each obj In ThisDrawing.ModelSpace
a = odRecordsCxT.Init(obj, False, False) 'table1
If Not odRecordsCxT.IsDone Then
ID = odRecordsCxT.Record.Item(0).Value
End If
b = odRecordsCx.Init(obj, True, False) 'table2
If Not odRecordsCx.IsDone Then
'Code for updating table 2
End If
Next
............................................................................
.............................................
But it is not working, as the second Init procedure (for table 2) returns
false.
If i opened the second ODRecords with OpenMode false, then i get a true
result for the init, but then i am not able to update the records.
If i switch the init´s order, then i get a 'true' result for table2, but
'false' for table1, even if on a OpenMode false.
If i try OpenMode false for both the ODRecords, then i can get acess to the
records, but i can´t update any of them.
So, it seems that for one single object, ther can be more than one opened
ODTable but only for readonly purposes. For updating, there can be only one
odtable opend.
Hpw can i solve my problem?
I am trying to, for each object, scan the contents of one ODTable, and then
change the records on another ODTable.
The chosen way is to create 2 diferent ODRecords for the same object at the
time. The first one is for scaning the data in the first table (openmode
false), and the other for updating the second table (openmode true).
I made this code:
............................................................................
...
Dim amap As AcadMap
Set amap =
ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application.2")
'ODRecords from ODTable1
Dim odRecordsCxT As odRecords
Set odRecordsCxT =
amap.Projects(ThisDrawing).ODTables.Item(ODtable1_name).GetODRecords
'ODRecords from ODTable2
Dim odRecordsCx As odRecords
Set odRecordsCx =
amap.Projects(ThisDrawing).ODTables.Item(ODTable2_name).GetODRecords
Dim obj As AcadObject
For Each obj In ThisDrawing.ModelSpace
a = odRecordsCxT.Init(obj, False, False) 'table1
If Not odRecordsCxT.IsDone Then
ID = odRecordsCxT.Record.Item(0).Value
End If
b = odRecordsCx.Init(obj, True, False) 'table2
If Not odRecordsCx.IsDone Then
'Code for updating table 2
End If
Next
............................................................................
.............................................
But it is not working, as the second Init procedure (for table 2) returns
false.
If i opened the second ODRecords with OpenMode false, then i get a true
result for the init, but then i am not able to update the records.
If i switch the init´s order, then i get a 'true' result for table2, but
'false' for table1, even if on a OpenMode false.
If i try OpenMode false for both the ODRecords, then i can get acess to the
records, but i can´t update any of them.
So, it seems that for one single object, ther can be more than one opened
ODTable but only for readonly purposes. For updating, there can be only one
odtable opend.
Hpw can i solve my problem?