CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

AddCustomObject 方法 (ActiveX)

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

AddCustomObject 方法 (ActiveX)

创建自定义对象。

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.AddCustomObject(ClassName)
对象

类型:模型空间纸空间

此方法应用到的对象。

类名

访问:仅输入

类型:字符串

必须在 ObjectARX® 应用程序 (ObjectARX DLL) 中定义 rxClassName,否则该方法将失败。

返回值 (RetVal)

类型:自定义对象

新创建的 Custom 对象。

言论

必须加载定义 rxClassName 定制类的 ObjectARX DLL。在 Application 对象上使用 LoadARX 方法显式加载 ObjectARX 文件。

例子

VBA:

Sub Example_AddCustomObject()
    ' This example adds a custom object to model space.
    
    ' Load the ObjectARX application that defines the custom object.
    ' Note: The application listed here does not exist and
    ' will cause an error when run. Change the application name
    ' to the path and name of your ObjectARX Application.
    ThisDrawing.Application.LoadArx "MyARXApp.dll"
    
    ' Once the application has been loaded successfully,
    ' add the custom object to model space.
    Dim customObj As AcadObject
    Set customObj = ThisDrawing.ModelSpace.AddCustomObject("MyNewObject")
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_AddCustomObject()
    ;; This example adds a custom object to model space.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Load the ObjectARX application that defines the custom object.
    ;; Note: The application listed here does not exist and
    ;; will cause an error when run. Change the application name
    ;; to the path and name of your ObjectARX Application.
    (vla-LoadArx acadObj "MyARXApp.dll")
    
    ;; Once the application has been loaded successfully,
    ;; add the custom object to model space.
    (setq customObj (vla-AddCustomObject (vla-get-ModelSpace doc) "MyNewObject"))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-6-27 16:11

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部