CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2024 开发者帮助

AddObject 方法 (ActiveX)

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

AddObject 方法 (ActiveX)

将对象添加到命名词典中。

支持的平台:仅限 Windows

签名

VBA:

RetVal = object.AddObject(Keyword, ObjectName)
对象

类型: 字典

此方法应用到的对象。

关键词

访问:仅输入

类型:字符串

要在此对象的字典中列出的关键字。

对象名称

访问:仅输入

类型:字符串

要在字典中创建的对象的 rxClassName。

返回值 (RetVal)

类型:对象

新创建的对象。

言论

此方法将 ObjectName 指定的新条目添加到字典中。如果该条目已存在,则将其替换为新对象。对象的名称由 Keyword 指定。

例如,可以将具有关键字“ThirdKeyword”和对象类型为“Object3”的对象添加到 MyDictionary 中以创建以下内容:

我的词典

关键字对象

FirstKeyword 对象 1

SecondKeyword 对象2

ThirdKeyword 对象3

注意:必须加载定义对象的 ObjectARX 应用程序,此方法才能正常运行。有关加载 ObjectARX 应用程序的信息,请参阅该方法。LoadARX

例子

VBA:

Sub Example_AddObject()
    ' This example creates a dictionary and adds
    ' a custom object to that dictionary.
    
    Dim dictObj As AcadDictionary
    Set dictObj = ThisDrawing.Dictionaries.Add("TEST_DICTIONARY")
    
    ' 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"
    
    ' Create the custom object in the dictionary
    Dim keyName As String
    Dim className As String
    Dim customObj As AcadObject
    
    keyName = "OBJ1"
    className = "CAsdkDictObject"
    
    Set customObj = dictObj.AddObject(keyName, className)
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_AddObject()
    ;; This example creates a dictionary and adds
    ;; a custom object to that dictionary.
    (setq acadObj (vlax-get-acad-object)
          doc (vla-get-ActiveDocument acadObj)
          dictionaries (vla-get-Dictionaries doc))
  
    (setq dictObj (vla-Add dictionaries "TEST_DICTIONARY"))
    
    ;; 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")
    
    ;; Create the custom object in the dictionary
    (setq keyName "OBJ1"
          className "CAsdkDictObject")

    (setq customObj (vla-AddObject dictObj keyName className))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-3-28 16:27

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部