CreateTypedArray 方法 (ActiveX) 
创建一个包含类型化参数数组的变体。 支持的平台:仅限 Windows 签名VBA: object.CreateTypedArray VarArr, Type, Value1, [value2, value3, ...valueN] 
 返回值 (RetVal)无返回值。 言论生成的变体可以传递到任何接受数字数组作为变体的 AutoCAD 方法或特性中。 此方法只能使用后期绑定编程技术进行访问。若要使用此方法,请将对象定义为 ,而不是 。UtilityObject (Dim myObj As Object)AcadUtility 例子VBA: Sub Example_CreateTypedArray()
    ' This example creates a spline from variant arrays created
    ' from doubles using the CreateTypedArray method.
    ' Note that this method must be late bound. This is done
    ' by declaring the utility object (utilObj) as Object,
    ' not as AcadUtility.
        
    Dim splineObj As AcadSpline
    
    ' Even though these are arrays, they are declared as variants
    Dim startTan As Variant
    Dim endTan As Variant
    Dim fitPoints As Variant
    
    Dim utilObj As Object   ' Late bound object
    Set utilObj = ThisDrawing.Utility
    
    ' Define the spline.
    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
    
    ' Create the spline
    Set splineObj = ThisDrawing.ModelSpace.AddSpline(fitPoints, startTan, endTan)
    ZoomAll
    
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_CreateTypedArray()
    ;; This example creates a spline from variant arrays created
    ;; from doubles using the CreateTypedArray method.
    ;; Note that this method must be late bound. This is done
    ;; by declaring the utility object (utilObj) as Object,
    ;; not as AcadUtility.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
   
    (setq utilObj (vla-get-Utility doc))
    
    ;; Define the spline.
    (vla-CreateTypedArray utilObj 'startTan vlax-vbDouble 0.5 0.5 0)
    (vla-CreateTypedArray utilObj 'endTan vlax-vbDouble 0.5 0.5 0)
    (vla-CreateTypedArray utilObj 'fitPoints vlax-vbDouble 0 0 0 5 5 0 10 0 0)
    
    ;; Create the spline
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq splineObj (vla-AddSpline modelSpace fitPoints startTan endTan))
    (vla-ZoomAll acadObj)
)
 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-4 19:41
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.