
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all.
I've recently opened a post on the Select method of the AcadSelectionSelect object as I couldn't get a good grasp of its use. Now I understand what it is for but I can't still fix a problem with my dynamic blocks that is about to make me lose it: the VBA code is ignoring them in the final tally. See code below for two different dynamic blocks "ModeloDeTransportadorEnAluminio" and "Modelo de transportador en forma de U".
The next snippet shows ZERO blocks for the count, ignoring all the dynamic block instances in the model space.
Sub FiltraTransportadorTipo1()
Dim MiFiltro As AcadSelectionSet
Dim TipodeFiltro(0) As Integer
Dim DatodeFiltro(0) As Variant
Dim i As Integer
Set MiFiltro = ThisDrawing.SelectionSets.Add("MisBloques")
TipodeFiltro(0) = 2
DatodeFiltro(0) = "ModeloDeTransportadorEnAluminio"
MiFiltro.Select acSelectionSetAll, , , TipodeFiltro, DatodeFiltro
MsgBox MiFiltro.Count
MiFiltro.Delete
End Sub
Whereas the next code is counting 3 out of 5 dynamic blocks, all of them on the same layer.
Sub FiltraTransportadorTipo2()
Dim MiFiltro As AcadSelectionSet
Dim TipodeFiltro(0) As Integer
Dim DatodeFiltro(0) As Variant
Dim i As Integer
Set MiFiltro = ThisDrawing.SelectionSets.Add("MisBloques")
TipodeFiltro(0) = 2
DatodeFiltro(0) = "Modelo de transportador en forma de U"
MiFiltro.Select acSelectionSetAll, , , TipodeFiltro, DatodeFiltro
MsgBox MiFiltro.Count
MiFiltro.Delete
End Sub
To add some information:
1) I've changed the SelectSimilar tool Settings to just the name, in case this was having an impact, especially in the second case given that it was considering the blocks on one of the layers (though it wouldn't explain why the count was zero for the first dynamic block that was only present on one layer). This didn't work out.
2) IMPORTANT. I used the oldschool Filter command. Well, it turns out I was facing the same issues, identical to those with the VBA code. The filter couldn't pick up the first dynamic block. And guess what...it was picking up 3 of the second type, just as the results with VBA. Why is this happening? I'm totally puzzled.
3) The Quick Select tool works like a charm. I wish there was something that could mimic it through code.
In addition, these dynamic blocks have one level of nested blocks, if that could be of relevance... But then again, if that was the issue, the code wouldn't pick up any instance at all.
I hope my problem is clear.
Solved! Go to Solution.