.NET

.NET

Reply
Active Contributor
kashi_rock
Posts: 48
Registered: ‎05-16-2006
Message 1 of 1 (212 Views)

Release AutoCAD object after reading object data using VB.NET

212 Views, 0 Replies
02-24-2008 11:00 PM
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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.