To obtain an object's property and change the property of an object (AutoLISP/ActiveX)

The value of a an object's property can be set and retrieved using ActiveX functions.

Note: ActiveX support in AutoLISP is limited to Windows only.

Obtain an object's property and apply the property to a new object

  1. At the Visual LISP Console window or AutoCAD Command prompt, enter an AutoLISP statement that gets or creates an object that contains the properties you want to work with.

    For example, this function call prompts you to pick a center point for a circle, then invokes the AddCircle method to draw the circle. The vlax-3d-point function converts the point you pick into the data type required by vla-addcircle.

    (setq 3dpt (vlax-3d-point (getpoint "\nPick the center point for a circle: "))
    (setq myCircle (vla-addcircle mspace 3dpt 2.0))
  2. Enter another AutoLISP statement that retrieves a property of the VLA-object and assigns it to another VLA-object.

    For example, use vla-get-center of a Circle object to draw concentric circles.

    (vla-addCircle mSpace (vla-get-center myCircle) 1.0)

Change the property of an object

  1. Obtain the current center point of the circle:
    (setq myCenter (vla-get-center myCircle))

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

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

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

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

    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: