Originally Posted by
ncraig122139
Thanks for the advice.
... your code does seem to select the block I want, but is unselected when the code finishes.
There must be something that unselects it in your code because it's running fine on my end. Perhaps a Thisdrawing.Regen statement after select command.
---
1. Directly, No, maybe because its read only. Indirectly, yes. My workaround will select it therefore it became the active selection set.
2. Probably. Why not use filters in Selection sets? Similar to QSelect features. (see sample code below.)
3. Why append if there's Nothing found?
By using Filters, your code can be simplified in this way.
Code:
Sub SelectBlocks()
Dim sSetBlocks As AcadSelectionSet
On Error Resume Next
Set sSetBlocks = ThisDrawing.SelectionSets.Add("SSET_BLOCKS")
If Err Then
Set sSetBlocks = ThisDrawing.SelectionSets("SSET_BLOCKS")
sSetBlocks.Clear
End If
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant
FilterType(0) = 0
FilterData(0) = "Insert"
sSetBlocks.Select acSelectionSetAll, , , FilterType, FilterData
End Sub
This will be faster because there will be no longer a need to iterate all objects and test if it is a block.