Page 1 of 1
Reading the number of instances of a block in the current dr
Posted: Mon May 10, 2004 7:50 am
by ENSIGN
Hi, i am trying to find the number of times a specific block has been inserted into the current drawing, can you please advice me on some coding to achieve this.
Posted: Mon May 10, 2004 11:05 am
by MROCK
Sure you could write some short lisp routine to do this, but maybe this little trick will helb you more quickly:
Type any command that needs selecting entities, for example COPY
ICAD wil prompt you to select entities, type PRO to select by properties.
Type NAME to select by block name.
Enter the blcokname, in the comand line ICAD will show you how many blocks has been selected.
------------------
Michael Röck
Posted: Tue May 11, 2004 3:53 am
by ENSIGN
Yes, it is quite easy to get this information from the CAD directly, but I was looking for a VBA coding way of obtaining the number of block references for a particular block definition
Posted: Tue May 11, 2004 4:37 am
by kenn
Try this:
Public Sub CountBlocks()
Dim dxfCode(1) As Integer, dxfValue(1) As Variant
Dim sBlockName As String
Dim ssBlocks As SelectionSet
sBlockName = InputBox("Block name?")
dxfCode(0) = 0
dxfValue(0) = "INSERT"
dxfCode(1) = 2
dxfValue(1) = sBlockName
Set ssBlocks = IntelliCAD.ActiveDocument.SelectionSets.Add("Blocks")
ssBlocks.Select vicSelectionSetAll, , , dxfCode, dxfValue
MsgBox "The number of " & sBlockName & " blocks is " & ssBlocks.Count & "."
End Sub
Posted: Wed May 12, 2004 1:52 am
by ENSIGN
Thx Kenn, thatb routine was just what i was looking for.