TheSwamp

Code Red => VB(A) => Topic started by: assafius on July 23, 2014, 03:48:33 AM

Title: Block instances
Post by: assafius on July 23, 2014, 03:48:33 AM
Hi all,

I've created an AcadBlock (with AutoCad VBA) and now I wish to count the number of instances of that
block within the modelspace.

Can anyone provide me with a brief code on this ?

Thanks a Bunch !
Title: Re: Block instances
Post by: IBIEINIID on August 15, 2014, 10:35:23 AM
dim ObjFind as AcadObject
dim BRFind as AcadBlockReference
dim BRCount as Integer

for each ObjFind in ThisDrawing.Modelspace
    if typeof ObjFind is AcadBlockReference then
        Set BRFind = ObjFind
        If BRFind.Name = "[Insert name of block from AutoCAD here]" Then
            BRCount = BRCount + 1
        End If
    End If
Next

that should work, with your number of instances stored in BRCount.