You can access an object’s properties using the wrapper functions that are created by importing a type library or directly with the use of the vlax-get-property and vlax-put-property functions.
After loading the ActiveX support functions with vl-load-com, you can use the vla-get- and vla-put- functions to get and set the values of an object’s property.
The vla-get-propertyname function returns the property of an object, while vla-put-propertyname function assigns a value to an object’s property. These functions require the following arguments:
For example, the following returns the AutoCAD application object's ActiveDocument property:
(vla-get-ActiveDocument (vlax-get-acad-object)) #<VLA-OBJECT IAcadDocument 00302a18>
The functions that start with vla- are wrapper functions for the AutoCAD type library, but the names of the wrapper functions for other type libraries will vary based on the prefixes you use. Importing a type library is ideal so you can see which functions are available to you using the Apropos window. However, not all properties, method, and constants in an imported type library are wrapped.
For example, there is no wrapper function available to obtain the CommandBars property of the Microsoft Word application object, but the following statement achieves this:
(setq ComBars (vlax-get-property msw 'CommandBars)) #<VLA-OBJECT CommandBars 0016763c>
The vlax-get-property function returns the property of an object, while the vlax-put-property function assigns a value to an object’s property. The functions require the following arguments:
You can use vlax-get-property (and vlax-put-property) even if a wrapper function is available.
For example, the following returns the AutoCAD application object's ActiveDocument property:
(vlax-get-property (vlax-get-acad-object) 'ActiveDocument) #<VLA-OBJECT IAcadDocument 00302a18>
Sometimes you can use pre-defined constants to update an object's property. For example, to set the fill color of a circle to green, you can use the constant acGreen instead of specifying a numeric index value:
(vla-put-color myCircle acGreen)
The ActiveX and VBA Reference lists any predefined constants under the entry describing the property. You can use these constants in Visual LISP ActiveX function calls.
Changing an object's property may not immediately affect the display of the object in the AutoCAD drawing. AutoCAD delays property changes to allow you to change more than one property at a time.
If you need to update the drawing window explicitly, issue the vla-update function:
(vla-update object)