thread687-1149218
The Original Thread was looking for a Way to Freeze Layers using Wildcards...
I wanted to offer this Alternative.
VBA Code is below the line
--------------------------------------
Public Sub Turn_off_Layers()
' Name The Sub anything that you choose
Dim objlayer As AcadLayer
Dim CurrLayer As AcadLayer
' set the first layer in the collection of layers
'(typically the 0 layer ) to Current
' Turn it on and thaw it if necessary
If ThisDrawing.Layers.Item(0).Freeze = True Then
ThisDrawing.Layers.Item(0).Freeze = False
End If
If ThisDrawing.Layers.Item(0).LayerOn = False Then
ThisDrawing.Layers.Item(0).LayerOn = True
End If
Set CurrLayer = ThisDrawing.Layers.Item(0)
ThisDrawing.ActiveLayer = CurrLayer
' End of Code Section to Freeze / Thaw / Set Current (0) Layer
' iterate through all Layer in the collection
For Each objlayer In ThisDrawing.Layers
' Test with wildcard to see if the current layer name
' in the for loop is similar to the string to test with
If objlayer.Name Like "*E-SYST-IDEN*" = True Then
objlayer.LayerOn = True
objlayer.Freeze = True
End If
' Add an If then block similar to the one above for each
' string you want to test for
' increment the for loop that iterates through the
' layers collection
Next objlayer
' regen the viewports so that the current state is reflected
ThisDrawing.Regen acAllViewports
' end the subroutine
End Sub
------------------------------------
This was tested in Autocad Architecture 2009
Using Microsoft VB 6.5
It works to turn off all layers that match the wild card string
resident file layers and xref'd layers
The Original Thread was looking for a Way to Freeze Layers using Wildcards...
I wanted to offer this Alternative.
VBA Code is below the line
--------------------------------------
Public Sub Turn_off_Layers()
' Name The Sub anything that you choose
Dim objlayer As AcadLayer
Dim CurrLayer As AcadLayer
' set the first layer in the collection of layers
'(typically the 0 layer ) to Current
' Turn it on and thaw it if necessary
If ThisDrawing.Layers.Item(0).Freeze = True Then
ThisDrawing.Layers.Item(0).Freeze = False
End If
If ThisDrawing.Layers.Item(0).LayerOn = False Then
ThisDrawing.Layers.Item(0).LayerOn = True
End If
Set CurrLayer = ThisDrawing.Layers.Item(0)
ThisDrawing.ActiveLayer = CurrLayer
' End of Code Section to Freeze / Thaw / Set Current (0) Layer
' iterate through all Layer in the collection
For Each objlayer In ThisDrawing.Layers
' Test with wildcard to see if the current layer name
' in the for loop is similar to the string to test with
If objlayer.Name Like "*E-SYST-IDEN*" = True Then
objlayer.LayerOn = True
objlayer.Freeze = True
End If
' Add an If then block similar to the one above for each
' string you want to test for
' increment the for loop that iterates through the
' layers collection
Next objlayer
' regen the viewports so that the current state is reflected
ThisDrawing.Regen acAllViewports
' end the subroutine
End Sub
------------------------------------
This was tested in Autocad Architecture 2009
Using Microsoft VB 6.5
It works to turn off all layers that match the wild card string
resident file layers and xref'd layers