Restore Layer Settings

AutoCAD ActiveX

 
Restore Layer Settings
 
 
 

The Restore method resets all layer settings in the current drawing to values that were saved earlier. For example, if you save the drawing's color and linetype settings under the name “ColorLinetype” and subsequently change those settings, restoring “ColorLinetype” resets the layers to the colors and linetypes they had when “ColorLinetype” was saved. If you add new layers to the drawing after saving “ColorLinetype,” those new layers are not affected when you restore “ColorLinetype.”

Restore the color and linetype settings of a drawing's layers

Assuming that the color and linetype settings of the layers in the current drawing were previously saved under the name “ColorLinetype,” the following code resets the color and linetype settings of each layer in the drawing to the value they had when “ColorLinetype” was saved.

Sub Ch4_RestoreLayerSettings()
    Dim oLSM As AcadLayerStateManager
    Set oLSM = ThisDrawing.Application. _
       GetInterfaceObject("AutoCAD.AcadLayerStateManager.17")
    oLSM.SetDatabase ThisDrawing.Database
    oLSM.Restore "ColorLinetype"
End Sub