ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ObjectARX and VBA

1 REPLY 1
Reply
Message 1 of 2
foley10x
368 Views, 1 Reply

ObjectARX and VBA

I am working a project in VBA in AutoCAD. I have created an object (via Class Module) that consists of several block references and other properties and methods. I would like to save these objects in the drawing database (persistence). In looking at XRECORD's it seems the class definition needs to be in a referenced DLL. Is their any way to designate a VBA class module as the object definition?

Or a more basic question is how to I add persistence (inside the DWG) to my objects and do I need ObjectARX to do it?

At this point I can do what I need to with XData, but I'm wondering if there's a better way. I expect this project to expand to the point that XDATA (and probably VBA) will not be practical. I've been doing VB 6 and VBA for a while, but I'm new to programing inside AutoCAD.

Thanks in advance
1 REPLY 1
Message 2 of 2
fenton.webb
in reply to: foley10x

If you are comfortable with VBA, stick with it for now - it's a good way into learning how autocad works. With that said, we consider VBA a non-professional API for AutoCAD and we prefer developers move to C# or VB.NET.

 

To answer your questions: Xrecords don't need an external DLL to use, so there's no worries there. They are built-in container objects, so use them as is. As far as designating a VBA class module as the object definition (deriving from XRECORD?) I don't believe that's possible.

 

Creating an XRecord and saving it to the DWG will give you your persistence. What you need to decide is where to save it - if it's to be associated with an entity then you will need to create an Extension Dictionary for the Entity and set the Xrecord in there. If it's to be a general container, one that saves drawing settings, etc, then you need access to the Named Objects Dictionary, and that's where you will set the Xrecord.

 

Using XData is absolutely fine! Xrecords and Xdata do the same thing, just in different ways... I recommend you take a look at this blog http://adndevblog.typepad.com/autocad/2012/07/the-right-tools-for-the-job-autocad-part-1.html

 

Also, check out the DevTvs amd labs here http://www.autodesk.com/developautocad




Fenton Webb
AutoCAD Engineering
Autodesk

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

Post to forums  

Autodesk Design & Make Report

”Boost