Problem with add selection

Problem with add selection

Anonymous
Not applicable
210 Views
1 Reply
Message 1 of 2

Problem with add selection

Anonymous
Not applicable
I want add an entity in a selection set only if this entity
have a determinated layer.

My wrong routine:

Dim SelObj As AcadSelectionSet
Dim Ent As AcadEntity
Dim EntAgg(0 To 1) As AcadEntity
Dim NameLayer As String 'name of the guide layer

..make a selection set

For Each Ent In SelObj
If Ent.Layer = NameLayer Then
Set EntAgg(0) = ThisDrawing.SelectionSets.Item(Ent)
SelParz.AddItems EntAgg
End If
Next Ent

Thx and sorry for my bad english
0 Likes
211 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Use a filter to selection entities on the layer you're interested in.

Public Sub createSelectionSet()
Const TARGET_LAYER_NAME = "0"

Dim selectionSet As AcadSelectionSet
Dim filterType(0) As Integer
Dim filterData(0) As Variant

For Each selectionSet In ThisDrawing.SelectionSets
If selectionSet.Name = "TEST" Then
selectionSet.Delete
Exit For
End If
Next selectionSet

filterType(0) = 8
filterData(0) = TARGET_LAYER_NAME

Set selectionSet = ThisDrawing.SelectionSets.Add("TEST")
selectionSet.Select acSelectionSetAll, , , filterType, filterData

MsgBox "Number of entities selected: " & CStr(selectionSet.Count)
selectionSet.Delete
End Sub
0 Likes