AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Active Contributor
Posts: 48
Registered: ‎05-16-2006
Message 1 of 5 (586 Views)

Release AutoCAD object after reading object data using VB.NET

586 Views, 4 Replies
02-25-2008 12:12 AM
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


'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
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
Posts: 4
Registered: ‎01-23-2008
Message 2 of 5 (586 Views)

Re: Release AutoCAD object after reading object data using VB.NET

04-17-2008 03:41 AM 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.

Posts: 4
Registered: ‎04-14-2009
Message 3 of 5 (586 Views)

Re: Release AutoCAD object after reading object data using VB.NET

05-30-2009 11:37 PM in reply to: kashi_rock
Did you sovle the release problem?I tried the TransactionManager's method but it didn't work.
*Expert Elite*
Posts: 1,049
Registered: ‎04-27-2009
Message 4 of 5 (586 Views)

Re: Release AutoCAD object after reading object data using VB.NET

06-01-2009 01:07 PM in reply to: kashi_rock
The OP is using Map COM API, which has nothing to do with Autodesk.AutoCAD.DatabaseServices.TransactionManager.
Posts: 242
Registered: ‎12-15-2011
Message 5 of 5 (186 Views)

Re: Release AutoCAD object after reading object data using VB.NET

07-24-2012 11:12 PM in reply to: kashi_rock

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

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!