Convert Arrays to Variants
From AutoCAD ActiveX
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 objectSet utilObj = ThisDrawing.Utility' Define the Spline ObjectutilObj.CreateTypedArray _startTan, vbDouble, 0.5, 0.5, 0utilObj.CreateTypedArray _endTan, vbDouble, 0.5, 0.5, 0utilObj.CreateTypedArray _fitPoints, vbDouble, 0, 0, 0, 5, 5, 0, 10, 0, 0Set splineObj = ThisDrawing.ModelSpace.AddSpline _(fitPoints, startTan, endTan)' Zoom in on the newly created splineZoomAllEnd Sub