AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

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

Release AutoCAD object after reading object data using VB.NET

589 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

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
Member
Veliv
Posts: 4
Registered: ‎01-23-2008
Message 2 of 5 (589 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.

VeliV
Member
reecho_cd
Posts: 4
Registered: ‎04-14-2009
Message 3 of 5 (589 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*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 4 of 5 (589 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.
Mentor
amitk_189
Posts: 242
Registered: ‎12-15-2011
Message 5 of 5 (189 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
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.