CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2022 开发者帮助

CreateTypedArray 方法 (ActiveX)

2024-5-18 18:44| 发布者: admin| 查看: 121| 评论: 0|原作者: admin|来自: AutoCAD

CreateTypedArray 方法 (ActiveX)

创建一个包含类型化参数数组的变体。

支持的平台:仅限 Windows

签名

VBA:

object.CreateTypedArray VarArr, Type, Value1, [value2, value3, ...valueN]
对象

类型: 实用程序

此方法应用到的对象。

VarArr

访问:仅输出

类型:变体

作为变体的值数组。

类型

访问:仅输入

类型:枚举VbVarType

您提供的值的类型。

vbBoolean或。vbIntegervbLongvbSinglevbDouble

值 1 [值 2, ...值N]

访问:仅输入

类型:在上面的 Type 参数中指定的类型。

要包含在变体中的值。

返回值 (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)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1   苏公网安备32011402011833)

GMT+8, 2025-3-14 05:52

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部