Counting Block references
I have a quick form set up with some common commands.
I am trying to get one to count blocks by name on a particular layer.
(IE count all the proposed fire hydrants, proposed manholes, etc)
if i use a for each block in thisdocument.blocks
then layer isnt a valid choice to filter on.
if i try to count block references, i cant get anything to run at all.
if i use the block.count property, i get all of them, regardless of layer
can anyone help?
let me know if more information is needed.
Dim intHyd As Integer
Dim intBbox As Integer
Dim cadBlock As AcadBlock
Dim cadBlocks As AcadBlocks
Set cadBlocks = ThisDrawing.Blocks
For Each cadBlock In cadBlocks
If cadBlock.Name = "HYD" Then
intHyd = intHyd + 1
End If
If cadBlock.Name = "BBOX" Then
intBbox = cadBlock.Count
End If
Next cadBlock
is what i have so far, then i use a msgbox to display it, but it doesnt work
RE: Counting BLock References
Correct. You need to expand the array to include a filter item for names. That's dxf group code 2.
ps. It helps to use code tags in your posts. They are available from the advanced editor. See the difference in your last post from the first one. It doesn't show as well in this case, because you already lost it, but code formatting is better preserved.
RE: Counting BLock References
it seems to be mostly working, but now i have a different but related problem:
one of my block references has a name of *U535 instead of "HYD" which its supposed to have, and i cant figure out why. i removed the object, and used the insert command to do it, but i still cant figure out why its not using the correct name.
any ideas?
(The count worked for one of the other blocks, so it apears to work okay, not the problem is in the block insertion in LDD)
RE: Counting BLock References
it is a dynamic block, but the 3 other blocks where the count is working are also dynamic.
is there a different function for counting dynamic blocks?
RE: Counting BLock References
Once you finished experimenting with your code, follow the 'Block Counter' link in my signature area. You can compare the code with yours and develop a better application. Remember...., the more you code yourself, the more you learn about the subject.