Specifies the name of the object.
Supported platforms: Windows only
VBA:
object.Name
Type: Application, Block, BlockReference, Dictionary, DimStyle, Document, ExternalReference, GeomapImage, Group, Layer, Layout, Linetype, Material, MenuGroup, MInsertBlock, MLeaderStyle, ModelSpace, PaperSpace, PlotConfiguration, PointCloud, PointCloudEx, PopupMenu, RasterImage, RegisteredApplication, Section, SelectionSet, Shape, TableStyle, TextStyle, Toolbar, ToolbarItem, UCS, View, Viewport, Wipeout, XRecord
The objects this property applies to.
Read-only: No (except for Application, Document, MenuGroup, ModelSpace, PaperSpace, SelectionSet, TextStyle objects)
Type: String
Name of the object.
Application, Document: This property returns the file name only, not the path.
ToolbarItem: This name is used as the tooltip text.
MenuGroup: The name is limited to 32 characters and cannot contain spaces or punctuation marks.
Raster: This property is similar to the ImageFile property, except that this property does not contain path information.
XRecord: The name of the object within the dictionary in which it resides. This name does not represent the class name of the object.
BlockRef: A block reference can be assigned the name of only a valid block definition in the drawing. Assigning a block reference a unique name will not automatically create a new block definition. To create a new block definition, use the Add method to add a new Block object to the Blocks collection.
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
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))
)