User defined object

User defined object

Anonymous
Not applicable
1,243 Views
1 Reply
Message 1 of 2

User defined object

Anonymous
Not applicable

Hello,

Is it possible to create a new object by using Autocad VBA just like a line or circle object?

I want to create an object named, let's say A4. It will have the points, name,  area properties.

In autocad It will draw the object and write the name inside the object as a text, and I want to select this object.

 

I created a class module A4 but does not know how to continue.

 

Option Explicit
Public Name As String
Public No As Long

Public Area As Double
Public plineObj As AcadPolyline

....

 

 

Sub A()

Dim P As A4' Declare.
Set P= New A4
P.No = 1
P.Draw
ZoomAll


End Sub

 

0 Likes
Accepted solutions (1)
1,244 Views
1 Reply
Reply (1)
Message 2 of 2

norman.yuan
Mentor
Mentor
Accepted solution

What you want to create is called custom entity (as opposed to AutoCAD native entity). No, you cannot create with VBA. The only way to create custom entity is to use ObjectARX/DBX C++, which is quite complicated.

 

If you want to go ahead to learn ObjectRAX/DBX C++ for custom entity, you also need to be aware that the custom entities would not be presented in regular AutoCAD unless your applicatin is installed (or the object enabler for your custom entity is installed along with AutoCAD). 

Norman Yuan

Drive CAD With Code

EESignature