i made a slight modification to some code that i found here in the forums, but how do i specify which blk name to count? I assume it has something to do with the grpCode and dataCode, but i dont know how to modify that section.
Code:
Public Function cntBlocks(layName As String, blkName As String) As Integer
'this counts the number of blocks with the given name and on the given layer
'declare variables
Dim blkSelSet As AcadSelectionSet
Dim blkRef As AcadEntity
Dim grpCode(0 To 3) As Integer
Dim dataCode(0 To 3) As Variant
'set initial values
grpCode(0) = -4
grpCode(1) = 0
grpCode(2) = 8
grpCode(3) = -4
dataCode(0) = "<AND"
dataCode(1) = "INSERT"
dataCode(2) = layName
dataCode(3) = "AND>"
'clear existing selection sets
For Each blkSelSet In ThisDrawing.SelectionSets
If blkSelSet.Name = "Sel_Blocks" Then
blkSelSet.Delete
Exit For
End If
Next blkSelSet
'get new selection set
Set blkSelSet = ThisDrawing.SelectionSets.Add("Sel_Blocks")
blkSelSet.Select acSelectionSetAll, , , grpCode, dataCode
'return results
cntBlocks = blkSelSet.Count
End Function