Filtering Layers.
Ever wondered how to filter your drawing for specific layers?
Well here's how. This application will filter your drawing for a specific
layer using the criteria that you will provide from within a sub-routine.
First of all the Function. Open a new module and add this coding :
Option Explicit
Public Function LayerSelection(strLayerName As String, strSSName) _
As AcadSelectionSet
Dim ssObjects As AcadSelectionSet
Dim intCode(0) As Integer
Dim varData(0) As Variant
Dim objCheck As AcadSelectionSet
'declare variables
intCode(0) = 8
'set variable for the dxf code for layer
varData(0) = strLayerName
'set variable for the layer name
Set ssObjects = ThisDrawing.SelectionSets.Add(strSSName)
'create a selection eset
ssObjects.Select acSelectionSetAll, , , intCode, varData
'select all entities on the specified layer
Set LayerSelection = ssObjects
'create a reference to the selection
End Function
Now add the sub-routine to run the function to the same module :
Public Sub FilterLayer()
Dim ssLayrObj As AcadSelectionSet
'declare variables
Set ssLayrObj = LayerSelection("0", "vbdset")
'get the entities on the layer "0"
Dim obj As Object
For Each obj In ssLayrObj
'for each of the entities
obj.Highlight True
'highlight them
Next
ThisDrawing.SelectionSets.Item("vbdset").Delete
'delete the selection set
End Sub
Run the macro "FilterLayer". All the entities on Layer 0 should
be highlighted.
Now you've got them, you can do anything you like with them.
But that, I will leave to your imagination.......
I would just like to thank Randall Raath for allowing me to 'steal' this.
(Saved me a lot of typing!!!!).
If you would like to download the source code for this Application/s, then
click Here