CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2020 开发者帮助

Name 属性 (ActiveX)

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

Name 属性 (ActiveX)

指定对象的名称。

支持的平台:仅限 Windows

属性值

只读:否(ApplicationDocumentMenuGroupModelSpacePaperSpaceSelectionSetTextStyle 对象除外)

类型:字符串

对象的名称。

言论

应用程序、文档:此属性仅返回文件名,不返回路径。

ToolbarItem:此名称用作工具提示文本。

MenuGroup:名称限制为 32 个字符,不能包含空格或标点符号。

栅格:此属性与属性类似,只是此属性不包含路径信息。ImageFile

XRecord:对象所在的字典中对象的名称。此名称不表示对象的类名。

BlockRef:只能为块参照指定图形中有效块定义的名称。为块引用指定唯一名称不会自动创建新的块定义。若要创建新的块定义,请使用该方法将新对象添加到集合中。AddBlockBlocks

例子

VBA:

Sub Example_Name()
    ' This example creates a new layer. It then
    ' changes the name of that layer.
    
    ' Add the new layer
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("NewLayer")
    
    ' Find the name of the new layer
    Dim layerName As String
    layerName = layerObj.name
    MsgBox "A new layer was created with the name: " & layerObj.name, , "Name Example"
    
    ' Change the name of the layer to "TEST". Note that behavior of the
    ' following code will be different for different objects. In some cases such as
    ' Block reference, changing the name means referencing to a new Block and therefore
    ' a Block with named "TEST" should already exist: otherwise an error will be
    ' returned.
    layerObj.name = "TEST"
    layerName = layerObj.name
    MsgBox "The new name of the layer is: " & layerObj.name, , "Name Example"
    
End Sub

可视化 LISP:

(vl-load-com)
(defun c:Example_Name()
    ;; This example creates a new layer. It then
    ;; changes the name of that layer.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Add the new layer
    (setq layerObj (vla-Add (vla-get-Layers doc) "NewLayer"))
    
    ;; Find the name of the new layer
    (setq layerName (vla-get-Name layerObj))
    (alert (strcat "A new layer was created with the name: " layerName))
    
    ;; Change the name of the layer to "TEST". Note that behavior of the
    ;; following code will be different for different objects. In some cases such as
    ;; Block reference, changing the name means referencing to a new Block and therefore
    ;; a Block with named "TEST" should already exist: otherwise an error will be
    ;; returned.
    (vla-put-Name layerObj "TEST")
    (setq layerName (vla-get-Name layerObj))
    (alert (strcat "The new name of the layer is: " layerName))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2025-1-19 06:48

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部