Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Just wanted to add another Possibility to the Original Thread

Status
Not open for further replies.

rkuhn68

Programmer
Jul 16, 2003
3
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top