AutoCAD ActiveX Automation provides a utility method to convert an array of data into a variant. This method is the CreateTypedArray method, which creates a variant that contains an array of integers, floating numbers, doubles, and so forth. You can pass the resulting variant into any AutoCAD method or property that accepts an array of numbers as a variant.
The CreateTypedArray method takes as input the type of values that are in the array, and the array of data to be converted. It returns the array of values as a variant.
Create a spline with the CreateTypedArray method
The following code converts three arrays using CreateTypedArray: the coordinates for a spline's fit points, and the start and end tangent of the spline. It then passes the variant into the AddSpline method to create the spline.
Sub Ch2_CreateSplineUsingTypedArray()
' This example creates a spline object in model space
' using the CreateTypedArray method.
Dim splineObj As AcadSpline
Dim startTan As Variant
Dim endTan As Variant
Dim fitPoints As Variant
Dim utilObj As Object ' late bind the Utility object
Set utilObj = ThisDrawing.Utility
' Define the Spline Object
utilObj.CreateTypedArray _
startTan, vbDouble, 0.5, 0.5, 0
utilObj.CreateTypedArray _
endTan, vbDouble, 0.5, 0.5, 0
utilObj.CreateTypedArray _
fitPoints, vbDouble, 0, 0, 0, 5, 5, 0, 10, 0, 0
Set splineObj = ThisDrawing.ModelSpace.AddSpline _
(fitPoints, startTan, endTan)
' Zoom in on the newly created spline
ZoomAll
End Sub