CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

删除方法 (ActiveX)

2023-1-4 04:42| 发布者: admin| 查看: 694| 评论: 0|来自: AutoCAD

摘要: 从字典中删除命名对象。

从字典中删除命名对象。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.Remove(Name)
对象

类型:字典

此方法适用的对象。

名字

访问:仅输入

类型:字符串

要从字典中删除的对象的名称(关键字)。

返回值(RetVal)

类型:对象

要从字典中删除的对象。

言论

例如,从以下字典中删除名为“FirstKeyword”的对象:

  • 我的词典
  • 关键字对象
  • 第一个关键字对象1
  • 第二关键字对象2

结果在以下字典中:

  • 我的词典
  • 关键字对象
  • 第二关键字对象2

例子

工 务 局:

Sub Example_Remove()
    ' This example creates a dictionary and adds
    ' a custom object to that dictionary. It then
    ' removes the object from the 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.arx"
    
    ' 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)
    
    ' Remove the object from the dictionary using the keyName
    dictObj.Remove keyName
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Remove()
    ;; This example creates a dictionary and adds
    ;; a custom object to that dictionary. It then
    ;; removes the object from the 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.arx")
    
    ;; Create the custom object in the dictionary
    (setq keyName "OBJ1")
    (setq className "CAsdkDictObject")
    
    (setq customObj (vla-AddObject dictObj keyName className))
    
    ;; Remove the object from the dictionary using the keyName
    (vla-Remove dictObj keyName)
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 13:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部