Creates a variant data type
(vlax-make-variant [value] [type])
Arguments
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.
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:
If you do not specify a type,vlax-vbEmpty
nil vlax-vbNull
:vlax-null vlax-vbLong
integer vlax-vbDouble
real vlax-vbString
string vlax-vbObject
VLA-object vlax-vbBoolean
:vlax-true, :vlax-false variant Same as the type of initial value
vlax-vbArray
vlax-make-safearray Return Values
The variant created.
Examples
vlax-make-variant:
Create a variant using the defaults for_$ (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 nil))
#<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 5))
#<variant 3 5>
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.
By default,Omitting the type argument for a string produces predictable results:
_$ (setq varstr (vlax-make-variant "ghost"))
#<variant 8 ghost>
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:
To create a variant containing arrays, you must specify type_$ (setq 4dubs (vlax-make-safearray vlax-vbDouble '(0 . 3)))
#<safearray...>
Then take the array of doubles and assign it to a variant:
_$ (vlax-make-variant 4dubs)
#<variant 8197 ...>
vlax-make-safearray, vlax-variant-change-type, vlax-variant-type, and vlax-variant-value functions. For more information on using variants, see Working with Variants in the AutoLISP Developer's Guide.
The