Turn Layers On and Off

AutoCAD ActiveX

 
Turn Layers On and Off
 
 
 

Turned-off layers are regenerated with the drawing but are not displayed or plotted. By turning layers off, you avoid regenerating the drawing every time you thaw a layer. When you turn a layer on that has been turned off, AutoCAD redraws the objects on that layer.

To turn layers on and off, use the LayerOn property. If you input a value of TRUE to this property, the layer is turned on. If you input a value of FALSE, the layer is turned off.

Turn off a layer

This example creates a new layer, adds a circle to the layer, then turns off the layer so that the circle is no longer visible.

Sub Ch4_LayerInvisible()
    ' Create a circle
    Dim circleObj As AcadCircle
    Dim center(0 To 2) As Double
    Dim radius As Double
    center(0) = 2: center(1) = 2: center(2) = 0
    radius = 1
    Set circleObj = ThisDrawing.ModelSpace. _
 AddCircle(center, radius)
      
    ' Create a new layer called "ABC"
    Dim layerObj As AcadLayer
    Set layerObj = ThisDrawing.Layers.Add("ABC")
      
    ' Assign the circle to the "ABC" layer
    circleObj.Layer = "ABC"
    circleObj.Update
      
    ' Turn off layer "ABC"
    layerObj.LayerOn = False
    ThisDrawing.Regen acActiveViewport
End Sub