VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

pulling object data and writing property set data

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
dwattersAMXH5
3293 Views, 8 Replies

pulling object data and writing property set data

hello, 

can anyone point me in the right direction to accomplish this task - 

i want to create a VBA to pull fields out of object data (from a pline created from shapefile) 
store the data as an attribute
use that attribute to automatically populate a pre-configured property set table in civil3d (so we can label and create tables with the property set data) 

then loop the functions to all lines selected so that each line gets its own specific object data plugged into its property set data. 


i am new to VBA but have experience with writing lisps, html, javascript so i'm excited to take on this vba project I just need some pointers in the right direction on how to accomplish it.  

ideally we would be able to select which object fields we wanted to copy over  (we have a list of about 20 - they are always named the same from GIS so simply creating generic variables for them wont be a problem) then with some "if selected = use, if not selected = dont use" 
would also like to get feedback from the program to tell if any fields that were selected were not used because property set fields didn't exist for that property that was copied. meaning you selected "field B" but there was no property set field using "field B"s information then it would return " "field B" data not transferred to Property Set Data " 


thanks for any advice! 

8 REPLIES 8
Message 2 of 9

Or better yet, 

any ideas on using Formula property definitions and pulling Object data to use.? 

this would work great if i could get some pointers on if or how to call that data in formula property definitons for property set data with VBA 


Message 3 of 9

RESULT="--"
ON ERROR RESUME NEXT

Dim ODrcs As ODRecords
Set amap = ThisDrawing.Application.GetInterfaceObject("AutoCADMap.Application")
Set ODrcs = amap.Projects.Item(ThisDrawing).ODTables.Item("FQN_ID").GetODRecords

RESULT= ODrcs

I was hoping this would work in formula property definition but i must be missing something - "fqn_id" being the field i am trying to pull OD from. 

i thought this would pull the ODrecord for that field and set it as variable "ODrcs" then show that variable as the result. 
but this is not the case 

Message 4 of 9
norman.yuan
in reply to: dwattersAMXH5

You did not mention, but seeing your recent post in "Civil 3D Customization" forum", I assume you are talking Object Data and PropertySet in Civil 3D. This forum is about AutoCAD VBA/COM API, which may cover COM API specific to AutoCAD verticals, such as Civil 3D, but history shows very, very few Civil3D COM API discussions happened here.

 

Anyway, here is what I know on this (I am no expert on this, just some investigation, as AutoCAD/Civil 3D programmer):

 

1. Object Data is exposed via COM API in AutoCAD Map (thus, Civil3D, too).

2. PropertySet is originally from AutoCAD Architecture, but brought into Civil3D (when Civil3D installed, there is "ACA" folder, meaning AutoCAD Architecture, underneath "AutoCAD 20xx" folder, in which the PropertySet related files are placed. However, as far as I know, there is no COM API access to PropertySet.

3. Both Object Data and PropertySet have been exposed in .NET APIs. I have done plenty of Object Data manipulation with Object Data, but haven't done anything with PropertySet, thus not sure if the API is fully capable of handing PropertySet data as the Civil3D UI does. 

 

Thus, I'll bet with .NET APIs available from Civil3D, pulling data from Object Data and populate PropertySet can be done, at least in most cases. 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 9
dwattersAMXH5
in reply to: norman.yuan

yes this is for Civil3d 

 

i would really like to do this with the formula property definition but i will look into creating a .net api! 
thank you for pointing me in a direction! 

if i am understanding correctly, 
i should be able to access OD and get a record for any chosen field per object (a PLine in my case)
set that record as a variable 
populate a property set field with that variable 
loop to all selected Plines 

all with .NET api? 

Message 6 of 9
norman.yuan
in reply to: dwattersAMXH5

I am not sure how much you have known/done with AutoCAD .NET API + Civil3D/MAP3D .NET API. Here are references in your .NET API DLL project you need:

 

1. the usual AutoCAD .NET assemblies (accoremgd/acdbmgd/acmgd.dll);

2. the usual Civil3D .NET API (AecBaseMgd/AeccBaseMgd.dll);

3. ManagedMapAPI.dll in AutoCAD installation folder "Map"

4. AecPropDataMgd.dll in AutoCAD installation folder "ACA"

 

If you have programming specific questions, it would be better post in "Civil3D Customization", or "AutoCAD .NET" forum.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 7 of 9
aammarJHHNU
in reply to: norman.yuan

Hi Norman,

Can i get an example of getting OD and pass it to an an acadattributreference ?

or just how to get OD;

Thanks

Message 8 of 9
norman.yuan
in reply to: dwattersAMXH5

AutoCAD Map/C3d has both COM API and .NET API for AutoCAD Map specific features, (just as plain AutoCAD has .NET API and COM API). Since you post in VBA forum, I assume you want to use Map's COM API in your VBA project.

 

For your requirement of passing OD data to block attributes, you would focus on how to have access to OD data attached to AcadEntity. Once you can retrieve the data (or attach OD data to AcadEntity, along the learning path), I assume you should be able to use the data from OD for any purpose, including updating AcadAttributeReference.

 

To deal with ObjectData in VBA, you need to add reference to Map's COM API type library (AcMapVbaApi.tlb):

normanyuan_0-1709557617468.png

Once the reference is added, off you go.

 

You can find sample VBA code that use Map's COM API in AutoCAD's installation folder:

 

C:\Program files/Autodesk/AutoCAD 202x\Map\Sample\VBA\MapSample.dvb.

 

You could also search Autodesk's discussion forums for "AutoCAD Map Development", but to be warned: there are not a lot discussion on Map's COM API: mostly are on .NET API.

 

If you have started working on plain AutoCAD ,NET API, then I'd suggest you not waste time on MAP's COM API, choose Map's .NET API instead, while you start learning. Also, if there is any chance your development would grow (most small coding project would end up this way!), it is time to stop wasting time on VBA. I'd proceed with MAP COM API only if it is a requirement of quick fix.

 

HTH

 

Norman Yuan

Drive CAD With Code

EESignature

Message 9 of 9
aammarJHHNU
in reply to: dwattersAMXH5

Thank you.

I think yes, it's time to move to .Net. I think I will use C# for development. VBA COM has limitations, and I think I have reached that limit. Any suggestions on how to start? I have the structure of object orientation, it's just a question of time and how to use the programming language.

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

Post to forums  

Autodesk Design & Make Report

”Boost