Constructing a Variant From a List of Points

So far, the data in the polypoints variable is in a list format suitable for many AutoLISP calls. However, the data is to be supplied as an input parameter to an ActiveX call that expects a variant array of doubles. You can use another utility function to make the required conversion from list to variant:

(defun gp:list->variantArray (ptsList / arraySpace sArray)
  ; allocate space for an array of 2d points stored as doubles
  (setq arraySpace (vlax-make-safearray
              vlax-vbdouble ; element type
              (cons 0
                    (- (length ptsList) 1)
                    ) ; array dimension
              )
  )

  (setq sArray (vlax-safearray-fill arraySpace ptsList))

  ; return array variant
  (vlax-make-variant sArray)
)

The following actions take place in gp:list->variantArray:

The following is an example of a function call that invokes gp:list->variantArray to convert a list to a variant array of doubles:

; data conversion from list to variant
(setq VLADataPts (gp:list->variantArray polypoints))