Counting specific blocks

Counting specific blocks

Anonymous
Not applicable
434 Views
5 Replies
Message 1 of 6

Counting specific blocks

Anonymous
Not applicable
I am having a problem counting blocks in a drawing. When the user inserts a block, I want the vba program to count how many similar blocks are in the drawing. I can accomplish part of this, but I hit two different snags. This first is the accuracy of the block count. I am tyring to use a filtered selection set to gather all of the blocks. I am using the filter type of "insert", but it doesn't seem to count all the block references? The example drawing I am testing this on contains 55 of these blocks but the count shows up as 13. If a block alread in the drawing gets copied instead of inserted, does this mess up the count? I have been using the (entget (car (entsel))) command to determine the type and name and the name seems to change sometimes after you copy the block. For example, after running the lsp on an inserted block, item 2 is "Trane FC-04". If I copy that block then run the lsp on the copied block, item 2 is still the same, but if the block is copied and then rotated, item 2 is "*U2335". But under autocad properties, the name still shows as "Trane FC-04". Why does this change? My second snag is selecting similar blocks since the same basic block has 2 or 3 sizes. The block names all start out similar so I am trying to utilize the Like method. This is also, not returning a correct number of blocks. Am I going about this the wrong way? I have included some of my code below. Thanks for your help.

Jason

Grps(0) = 0: Dats(0) = "Block Reference"
Grps(1) = 2: Dats(1) = ""
On Error Resume Next
Set SS = ThisDrawing.SelectionSets.Add("SS")
If Err.Number <> 0 Then
Set SS = ThisDrawing.SelectionSets.Item("SS")
End If
SS.Clear

match1 = "*" & Left(NewBlk.Name, 9) & "*"
Dats(1) = match1
Filter1 = Grps
Filter2 = Dats
SS.Select acSelectionSetAll, , , Filter1, Filter2
intBlockCounter = SS.count

Message was edited by: test_52

Message was edited by: test_52 Message was edited by: test_52
0 Likes
435 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
After doing a little more digging, I found that after the dynamic block is inserted into the drawing, the block name is still intact. But if the dynamci block is rotated (using the rotate method in the dynamic block), the block name changes. Why does it do this? Is there anyway to stop this from occurring. Once it changes, there is now way to get it back (that I can find). Please help!
Jason
0 Likes
Message 3 of 6

Anonymous
Not applicable
Get the EffectiveName of the blocks. Note that I don't beleive this is a
filterable item......so you will need to get a selections set of all INSERTS
(not BlockReferences) and cycle through looking for the EffectiveName.

Jeff

wrote in message news:5152591@discussion.autodesk.com...
After doing a little more digging, I found that after the dynamic block is
inserted into the drawing, the block name is still intact. But if the
dynamci block is rotated (using the rotate method in the dynamic block), the
block name changes. Why does it do this? Is there anyway to stop this from
occurring. Once it changes, there is now way to get it back (that I can
find). Please help!
Jason
0 Likes
Message 4 of 6

Anonymous
Not applicable
That's what I was afraid of. I was trying to avoid iterating thru all blocks because some of our drawings have quite a few blocks and it takes awhile cycling thru all of them. Thanks for your help!
Jason
0 Likes
Message 5 of 6

Anonymous
Not applicable
To speed it up a bit, just filter for the Block name AND Anonymous blocks.

FilterData(0) = "BLOCKNAME,`*U#*"


wrote in message news:5152670@discussion.autodesk.com...
That's what I was afraid of. I was trying to avoid iterating thru all
blocks because some of our drawings have quite a few blocks and it takes
awhile cycling thru all of them. Thanks for your help!
Jason
0 Likes
Message 6 of 6

Anonymous
Not applicable
Thanks, that helps alot!

Jason
0 Likes