将对象添加到命名字典。 支持的平台:仅窗口 签名工 务 局: RetVal = object.AddObject(Keyword, ObjectName)
言论此方法将对象名称指定的新条目添加到字典中。如果该条目已存在,则将其替换为新对象。对象的名称由关键字指定。 例如,可以将具有关键字“ThirdKeyword”和对象类型“Object3”的对象添加到 MyDictionary 以创建以下内容: 我的词典 关键字对象 第一个关键字对象1 第二关键字对象2 第三关键字对象3 注意:必须加载定义对象的 ObjectARX 应用程序,此方法才能正常运行。有关加载 ObjectARX 应用程序的信息,请参阅该方法。LoadARX
例子工 务 局: 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 Visual 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)) (setq doc (vla-get-ActiveDocument acadObj)) (setq 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") (setq className "CAsdkDictObject") (setq customObj (vla-AddObject dictObj keyName className)) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:49
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.