Rename Objects

AutoCAD ActiveX

 
Rename Objects
 
 
 

As your drawings become more complex, you can rename objects to keep the names meaningful or to avoid conflicts with names in other drawings you have inserted in the main drawings.

You can rename any named object except those that AutoCAD names by default, for example, layer 0 or the CONTINUOUS linetype.

Names can be up to 255 characters long. In addition to letters and numbers, names can contain spaces (although AutoCAD removes spaces that appear directly before and after a name) and any special character not used by Microsoft Windows or AutoCAD for other purposes. Special characters that you cannot use include less-than and greater-than symbols (< >), forward slashes and backslashes (/ \), quotation marks ("), colons (:), semicolons (;), question marks (?), commas (,), asterisks (*), vertical bars (|), equal signs (=), and single quotes ('). You also cannot use special characters created with Unicode fonts.

To rename an object, use the Name property for that object.

Rename a layer

This example creates a layer called “NewLayer” and then renames the layer to “MyLayer”.

Sub Ch4_RenamingLayer()
    ' Create a layer
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("NewLayer")
      
    ' Change the name of the layer
    layerObj.Name = "MyLayer"
      
End Sub