Creates a variant data type

(vlax-make-variant [value] [type])



The value to be assigned to the variant. If omitted, the variant is created with the vlax-vbEmpty type (uninitialized).


The type of variant. This can be represented by one of the following constants:

vlax-vbEmpty (0) Uninitialized (default value)

vlax-vbNull (1) Contains no valid data

vlax-vbInteger (2) Integer

vlax-vbLong (3) Long integer

vlax-vbSingle (4) Single-precision floating-point number

vlax-vbDouble (5) Double-precision floating-point number

vlax-vbString (8) String

vlax-vbObject (9) Object

vlax-vbBoolean (11) Boolean

vlax-vbArray (8192) Array

The integer shown in parentheses indicates the value to which the constant evaluates. It is recommended that you specify the constant in your argument, not the integer value, because the value may change in later releases of AutoCAD.

If you do not specify a type, vlax-make-variant assigns a default data type based on the data type of the value it receives. The following list identifies the default variant data type assigned to each LISP data type:







:vlax-true, :vlax-falsevlax-vbBoolean

variant Same as the type of initial value


Return Values

The variant created.


Create a variant using the defaults for vlax-make-variant:

_$ (setq varnil (vlax-make-variant))
#<variant 0 >

The function creates an uninitialized (vlax-vbEmpty) variant by default. You can accomplish the same thing explicitly with the following call:

_$ (setq varnil (vlax-make-variant
#<variant 0 >

Create an integer variant and set its value to 5:

_$ (setq varint (vlax-make-variant
5 vlax-vbInteger))
#<variant 2 5>

Repeat the previous command, but omit the type argument and see what happens:

_$ (setq varint (vlax-make-variant
#<variant 3 5>

By default, vlax-make-variant assigned the specified integer value to a Long integer data type, not Integer, as you might expect. This highlights the importance of explicitly stating the type of variant you want when working with numbers.

Omitting the type argument for a string produces predictable results:

_$ (setq varstr (vlax-make-variant
#<variant 8 ghost>

To create a variant containing arrays, you must specify type vlax-vbArray, along with the type of data in the array. For example, to create a variant containing an array of doubles, first set a variable's value to an array of doubles:

_$ (setq 4dubs (vlax-make-safearray
vlax-vbDouble '(0 . 3)))

Then take the array of doubles and assign it to a variant:

_$ (vlax-make-variant 4dubs)
#<variant 8197 ...>
See Also