AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Release AutoCAD object after reading object data using VB.NET

4 REPLIES 4
Reply
Message 1 of 5
kashi_rock
896 Views, 4 Replies

Release AutoCAD object after reading object data using VB.NET

I am developing an application to customize an AutoCAD using VB.NET. Earlier I develop such type of application using AutoCAD VBA but this time I use VB.NET to make a separate windows based application. Where there is a need to read the object data attached on the entity. I am successfully read the object’s object data from the AutoCAD entity but after that when I try to modify that object it displays an error message that “Object is open for read”. I think it is not releasing the object after initialization for read object data.

Here is my code that I used to read the object data:

Public Function acdGetObjectDataObjId(ByRef acdObject As AcadObject) As Long

Dim AcadMap As AcadMap
Dim ODfdfs As ODFieldDefs
Dim ODrcs As ODRecords
Dim boolVal As Boolean
Dim acdActiveDocument As AcadDocument

Try

'Open AutoCAD application if not opened
If acdApplication Is Nothing Then
acdApplication = acdOpenAutoCADApplication()
End If

'Get the active document
acdActiveDocument = acdApplication.ActiveDocument

AcadMap = CType(acdActiveDocument.Application.GetInterfaceObject("AutocadMAP.Application.3"), AcadMap)

'Get object data table
ODfdfs = AcadMap.Projects.Item(0).MapUtil.NewODFieldDefs

ODrcs = AcadMap.Projects.Item(acdActiveDocument).ODTables.Item("GISINW").GetODRecords

boolVal = ODrcs.Init(acdObject, False, False)

'Return green ObjectID
acdGetObjectDataObjId = ODrcs.Record.Item("ID_GISINW").Value

Catch ex As Exception
'Return 0 if any error occured
acdGetObjectDataObjId = 0
Finally
ODrcs = Nothing
ODfdfs = Nothing
AcadMap = Nothing
End Try

End Function

Please guide me where I am doing wrong. I look forward to hear from you.

Buddhi Prasad Koirala
Software Engineer
DHV Global Engineering Center BV
4 REPLIES 4
Message 2 of 5
Veliv
in reply to: kashi_rock

Hi Buddhi,

you should use Autodesk.AutoCAD.DatabaseServices.TransactionManager when you try to read or modify entity OD table records.

VeliV
Message 3 of 5
reecho_cd
in reply to: kashi_rock

Did you sovle the release problem?I tried the TransactionManager's method but it didn't work.
Message 4 of 5
norman.yuan
in reply to: kashi_rock

The OP is using Map COM API, which has nothing to do with Autodesk.AutoCAD.DatabaseServices.TransactionManager.
Message 5 of 5
amitnkukanur
in reply to: kashi_rock

But without using Autocad MAP can we fetch the data of autocad

Senior Software Engineer

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost