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: 

AutoCAD MAP 3D element object data

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Raimo.Lust
1516 Views, 5 Replies

AutoCAD MAP 3D element object data

Can anyone help me with the VBA code by which I can get the value of a certain element object data data table ("OD:veetorud") of a certain object data field("Läbimõõ")?



5 REPLIES 5
Message 2 of 6
norman.yuan
in reply to: Raimo.Lust

AutoCAD Map (or Civil) installation comes with VBA code sample showing how to access Map objects with COM API (such as ObjectData). it is located at (MapSamples.dvb)

C:\Program Files\Autodesk\AutoCAD 20xx\Map\Sample\VBA

 

Simply load this DVB into AutoCAD Map with command VBAMAN.

 

Since you are most likely use much newer version of AutoCAD Map while this sample DVB project was created with very old version of AutoCAD Map and have been there for many years, after opening it in VBA Editor, you need to go to Menu->Tools->References... to open "References" dialog box, where you would more than likely see something like "MISSING: Autodesk Map 3D 2005".  Go ahead to uncheck the item, and then scroll down the list to find something like "AutoCAD Map 3D 20xx", highlight it and pay attention to its location below the list box. It should be in the same folder as C:\Program Files\Autodesk\AutoCAD 20xx\Map\. Then check the item, click OK to close the dialog box.

 

Now you can study/test-run the sample code. For dealing with ObjectData, the related code are ties in FormOD and FormODShow in the sample project.

 

HTH

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 6
Raimo.Lust
in reply to: norman.yuan

Sample code gives error on the same line

Message 4 of 6
norman.yuan
in reply to: Raimo.Lust

do not have AcadMap 2019 available at hand. But with my Acad Civil3D 2021 following code works as expected

 

Dim mapAa As AcadMap

Set acadMap=ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")

 

You can also try "AutoCADMap.Application.5"

 

Do you have different versions of AutoCAD Map/Civil other than 2019 installed in the same computer? Or do you have have other AutoCAD session running besides the AutoCAD Map session running your VBA code?

 

Also one should not use GetObject(, "AutoCAD.Application") inside AutoCAD VBA code to reach current AutoCAD running session, if there is possibility of multiple AutoCAD sessions are running in the same computer, because GetObject() does not guarantee returning the same AutoCAD session where your VBA code is running in. Yes I see, this bad practice is from Autodesk provided sample, nonetheless, it is bad, whether it is the cause of your issue or not.

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 6
Raimo.Lust
in reply to: norman.yuan

I have also have diffrent AutoCAD Civil 3D versions and seems that this causes the problem because I tried the same code on colleague´s computer and it worked. Do you know how to fix it or I have to make clean Windows install?

Message 6 of 6
norman.yuan
in reply to: Raimo.Lust

If I were you, I would try to repair the latest version of Civil/Map (2019?) installed in your computer, and only do the VBA work with the latest version.

 

Since AcMapVbApi.dll is a COM API component, it is known that different versions could cause issue like this (DLL Hell). 

 

If you are doing serious business programming task, it would be better move on to AutoCAD/Map .NET API instead of VBA/COM, IMO.

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

Autodesk Design & Make Report