×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Just wanted to add another Possibility to the Original Thread

Just wanted to add another Possibility to the Original Thread

Just wanted to add another Possibility to the Original Thread

(OP)
thread687-1149218: FREEZING A LIST OF LAYERS WITH VBA?

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  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close