PDA

View Full Version : Filtering layers in vba


test_52
06-05-2005, 08:38 PM
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

Eddie
08-05-2005, 09:46 PM
8) You could try something like this...

Sub layerchng()
Dim Layrs As AcadLayers
Dim iLayer As AcadLayer

Set Layrs = ThisDrawing.Layers

For Each iLayer In Layrs

If LCase$(iLayer.Name) Like "*pipe*" Then
iLayer.Color = acGreen
End If

Next
End Sub