About Safearrays with Variants (AutoLISP/ActiveX)

Safearray data must be passed to ActiveX methods through variants.

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

Before you can assign values to a safearray, you must first create it. Then the safearray can be assigned to a variant before passing it to a method. For methods that require a three-element array of doubles (typically to specify a point), you can use the vlax-3d-point function to build the required data structure.

For example, the following call takes a list of points and converts the list into an array of three doubles:

(setq circCenter (vlax-3d-point '(3.0 3.0 0.0)))
#<variant 8197 ...>

You can also pass vlax-3d-point two or three numbers, instead of a list. For example:

(setq circCenter (vlax-3d-point 3.0 3.0))
#<variant 8197 ...>

When you omit the third point, vlax-3d-point sets it to zero. You can use vlax-safearray->list to verify the contents of the variable set by vlax-3d-point:

(vlax-safearray->list (vlax-variant-value circcenter))
(3.0 3.0 0.0)

The vlax-TMatrix function performs a similar task for transformation matrices, which are required by the vla-TransformBy function. It builds the transformation matrix from four lists of four numbers each, converting all numbers to reals, if necessary. For example:

(vlax-tmatrix '((1 1 1 0) (1 2 3 0) (2 3 4 5) (2 9 8 3)))
#<variant 8197 ...>

If you need to create a variant for an array containing anything other than three doubles or a transformation matrix, you must build it yourself.