AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Active Contributor
48 Posts
0 Kudos
Registered: ‎05-16-2006
Post 1 of 5

Release AutoCAD object after reading object data using VB.NET

593 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
4 Posts
0 Kudos
Registered: ‎01-23-2008
Post 2 of 5

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
4 Posts
0 Kudos
Registered: ‎04-14-2009
Post 3 of 5

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*
1,084 Posts
215 Kudos
Registered: ‎04-27-2009
Post 4 of 5

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
242 Posts
16 Kudos
Registered: ‎12-15-2011
Post 5 of 5

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