CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

名称属性 (ActiveX)

2023-1-3 10:27| 发布者: admin| 查看: 374| 评论: 0|来自: AutoCAD

摘要: 指定对象的名称。

指定对象的名称。

支持的平台:仅窗口

签名

工 务 局:

object.Name
对象

类型:应用程序,块,块引用,比较引用,字典暗淡样式,文档外部引用地理地图图像,组,图层布局线型材料菜单最小块MLeader样式,模型空间,图纸空间绘图配置,点云,点云Ex弹出菜单光栅图像注册应用程序部分选择集形状,表格样式,文本样式,工具栏,工具栏项UCS视图视口擦除,XRecord

此属性适用的对象。

属性值

只读:否(应用程序,文档菜单组,模型空间,图纸空间选择集文本样式对象除外)

类型:字符串

对象的名称。

言论

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

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

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

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

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

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

例子

工 务 局:

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

Visual 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 )

GMT+8, 2024-5-19 14:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部