I am trying to remove the OD record from an object, but keep getting a Mapexception error on the GetObjectTableRecords.
Dim myTables As Autodesk.Gis.Map.ObjectData.Tables = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.ODTables
Dim table As Autodesk.Gis.Map.ObjectData.Table= myTables("MyTable")
Dim recs As Autodesk.Gis.Map.ObjectData.Records
recs = table.GetObjectTableRecords(0, ent.ObjectId, Autodesk.Gis.Map.Constants.
OpenMode.OpenForWrite, True)
Dim ie AsIEnumerator
ie = myRec.GetEnumerator
ie.MoveNext()
myRec.RemoveRecord()
myRec.Dispose()
I just started working with VB.NET and AutoCAD Map 3D myself, so I'm not sure how helpful I can be, but I'll try :-).
If you put the GetObjectTableRecords call inside a Try...Catch block, can you get any more details about the error? Or perhaps try to figure out how to use the Autodesk.AutoCAD.Runtime.Exception class to get more information on the error.
My guess would be that your ent.ObjectID is not set correctly, but that's all it is, a guess.
Actually, it looks like my two suggestions are really the same. It seems like you would use:
Try recs=table.GetObjectTableRecords(0, ent.ObjectID, Autodesk.Gis.Map.Constants.OpenMode.OpenForWrite, True) Catch MyException as Autodesk.AutoCAD.Runtime.Exception 'use MyException properties and methods to display info on the error here End Try