指定对象的名称。 支持的平台:仅窗口 签名工 务 局: object.Name 言论应用程序、文档:此属性仅返回文件名,而不返回路径。 工具栏项:此名称用作工具提示文本。 菜单组:名称限制为 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)) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:29
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.