Updating Object Properties
 
 
 

Functions that update properties are prefixed with vla-put and use the following syntax:

(vla-put-propertyobjectnew-value)

For example, vla-put-center changes the center point of a circle.

To change the X axis of a circle

  1. Obtain the current center point of the circle:
    _$ (setq myCenter (vla-get-center
    myCircle))
    
    #<variant 8197 
    

    The center point is returned in a variant of type safearray. The safearray contains three doubles (X, Y, and Z coordinates).

  2. Save the center point in list form:
    $ (setq centerpt (vlax-safearray->list
    
      (vlax-variant-value
    myCenter)))
    
    (17.8685 5.02781 0.0)
    

    Converting the center point from a variant safearray to a list makes it easier to modify the coordinates.

  3. Subtract 1 from the X axis of the center point:
    _$ (setq newXaxis (-
    (car centerpt) 1))
    
    16.8685
    

    The result is saved in variable newXaxis.

  4. Construct a new point list for the center point, using the new X axis and the original Y and Z values:
    _$ (setq newcenter (list
    newXaxis  (cadr centerpt)
    
       (caddr centerpt)))
    
    (16.8685 4.52594 0.0)
    

    The constructed list is saved in variable newcenter.

  5. Use vla-put-center to update the circle with the new X axis:
    _$ (vla-put-center myCircle
    (vlax-3d-point newcenter))
    
    nil
    

    Note that this command uses vlax-3d-point to convert the new center point list into the data type required by vla-put-center.

    The AutoCAD drawing window shows the result:

Note that 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)

Sometimes you can use pre-defined constants to update an object's property. For example, to set the fill color of a circle to red, you can use the constant acRed instead of specifying a numeric index value:

(vla-put-color myCircle acRed)

The ActiveX and VBA Reference lists any predefined constants under the entry describing the property. You can use these constants in VLISP ActiveX function calls.