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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filtering layers in vba

Status
Not open for further replies.

jbone52

Technical User
Apr 29, 2005
7
US
I am trying to find a quicker way to change the color of certain layers. I don't want to list each layer that I want changed. Is there a way to filter out certain layers according to their name? For example I have the following layers:
H-equip piped
H-duct
H-pipe
H-hatch

Is it possible to select all of the layers that contain the string "pipe"? That way I can change the color of the layers that contain "pipe" but not the others.

Any help would be great!

Jason
 
Just iterate through the layers collection and look for the name string in the layer.name
 
Would you be able to post some code on how to accomplish this? I thought I understood how to do this but I couldn't get it to work.

Jason
 
Dim acLyrs As AcadLayers
Dim acLyr As AcadLayer
'''''''''''''''''''''''''''''''''''''''
On Error GoTo ErrHandler

Set acLyrs = ThisDrawing.Layers

For Each acLyr In acLyrs
If instr(acLyr.name, partOfSomeLayerName) Then
aclyr.color = yourNewLayerColor
End If
Next acLyr
 
Thanks for the help! I finally got it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top