The RenameLayerState method renames a saved layer state from one name to another in a drawing. The following code renames the ColorLinetype layer settings to OldColorLinetype.
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
<CommandMethod("RenameLayerState")> _
Public Sub RenameLayerState()
'' Get the current document
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acLyrStMan As LayerStateManager
acLyrStMan = acDoc.Database.LayerStateManager
Dim sLyrStName As String = "ColorLinetype"
Dim sLyrStNewName As String = "OldColorLinetype"
If acLyrStMan.HasLayerState(sLyrStName) = True And _
acLyrStMan.HasLayerState(sLyrStNewName) = False Then
acLyrStMan.RenameLayerState(sLyrStName, sLyrStNewName)
End If
End Sub
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
[CommandMethod("RenameLayerState")]
public static void RenameLayerState()
{
// Get the current document
Document acDoc = Application.DocumentManager.MdiActiveDocument;
LayerStateManager acLyrStMan;
acLyrStMan = acDoc.Database.LayerStateManager;
string sLyrStName = "ColorLinetype";
string sLyrStNewName = "OldColorLinetype";
if (acLyrStMan.HasLayerState(sLyrStName) == true &&
acLyrStMan.HasLayerState(sLyrStNewName) == false)
{
acLyrStMan.RenameLayerState(sLyrStName, sLyrStNewName);
}
}