When working with the ActiveX support and core AutoLISP functions, you will need to convert between data types.
Adding a circle to a drawing with the AddCircle method requires you to specify a center point and radius for the circle. These arguments are referred to as Center and Radius. Center is defined as a variant (three-element array of doubles), and Radius is listed as a double:
(setq RetVal (vla-AddCircle aMSpace Center Radius))
Variants are essentially self-defining structures that can contain different types of data. For example, strings, integers, and arrays can all be represented by variants. Stored along with the data is information identifying the type of data. This self-defining feature makes variants useful for passing parameters to ActiveX servers, because it enables servers based on any language to understand the data value.
ActiveX supports many data types that are similar to those in AutoLISP, but there are a few unique data types that do not directly map to those supported by AutoLISP. The following explains how to convert the data types:
The ActiveX array data type are similar to a list in AutoLISP. They contain multiple elements that represent different data structures. A common use for an array is to represent a coordinate value. You can use vlax-safearray->list to convert an array to a list. Converting a list to an array requires you to define the data type and number of elements the array should have with vlax-make-safearray, and assign the values of the list to the elements of the array using the vlax-safearray-fill.
Variant data types are used when a method might return or use more than one type of data. You can use vlax-make-variant to create a variant. When creating a variant, you specify the type of data and value it should hold. If a variant is returned by a method or property, you can use the vlax-variant-type and vlax-variant-value functions.
(setq MSpace (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)))) #<VLA-OBJECT IAcadModelSpace 0000000030434638> (setq circObj (vla-AddCircle MSpace (vlax-3d-point '(5.0 5.0 0.0)) 3)) #<VLA-OBJECT IAcadCircle 00000000303b2698> (vlax-vla-object->ename circObj) <Entity name: 7ffffb05de0>
(setq en (handent handle-circle)) <Entity name: 27f0538> (setq en (car (entsel "\nSelect circle: "))) <Entity name: 27f0538> (vlax-ename->vla-object en) #<VLA-OBJECT IAcadCircle 00000000303b3718>
Returned by vla-get-handle or by retrieving the DXF 5 group code from an entity name’s association list, which entities retain across AutoCAD sessions. Use vla-handleToObject to return the VLA-object that is associated with the handle.
(vla-get-handle vla-circle) "4F" (setq handle-circle (cdr (assoc 5 (entget ename-circle)))) "4F" (setq vla-circle (vla-handleToObject acadDocument handle-circle)) #<VLA-OBJECT IAcadCircle 03642c24>
Used by ActiveX, ObjectARX, and Manage .NET programs to identify objects. Use vla-ObjectIDToObject to convert an object ID to a VLA-object or use vla-get-ObjectID to convert a VLA-object to an object ID.
(setq objid-Circle (vla-get-objectid vla-circle)) 41878840 (vla-ObjectIDtoObject acadDocument objid-circle) #<VLA-OBJECT IAcadCircle 03642c24>