About Using ActiveX with AutoLISP (AutoLISP/ActiveX)

 
 
 

ActiveX Automation is a way to work programmatically with the contents of a drawing and other Windows applications that support ActiveX methodology.

NoteActiveX support in AutoLISP is limited to Windows only.

In many instances, ActiveX works faster than traditional AutoLISP functions in manipulating AutoCAD drawing objects. The ActiveX programming interface is usable in a number of languages and environments. When you work with ActiveX objects in AutoLISP, you work with the same object model, properties, and methods that can be manipulated from other programming environments.

Objects are the main building blocks of an ActiveX application. In some ways, you are already familiar with this notion. For example, AutoCAD drawing items such as lines, arcs, polylines, and circles have long been referred to as objects. But in the ActiveX schema, the following AutoCAD components are also represented as objects:

Even the drawing and the AutoCAD application itself are considered objects.

ActiveX includes much of the functionality provided by standard AutoLISP functions such as entget, entmod, and setvar. Compared to these functions, ActiveX runs faster and provides easier access to object properties. For example, to access the radius of a circle with standard AutoLISP functions, you must use entget to obtain a list of entities and assoc to find the property you want. You must also know the code number (DXF group value) associated with that property to obtain it with assoc, as shown in the following example:

(setq radius (cdr (assoc 40 (entget circle-entity))))

With an ActiveX function, you simply ask for the radius of a circle as follows:

(setq radius (vla-get-radius circle-object))