to count number of blocks

to count number of blocks

Anonymous
Not applicable
792 Views
8 Replies
Message 1 of 9

to count number of blocks

Anonymous
Not applicable
How can I count the number of blocks I have in my drawing
0 Likes
793 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable

Here's something I've had kicking around for
years.  It's not pretty but it should get you going in the right
direction.

 


--
Matt W
"Children are like TV sets. When they start acting
weird, whack them across the head with a big rubber basketball shoe."

 

 


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
How
can I count the number of blocks I have in my drawing
0 Likes
Message 3 of 9

Anonymous
Not applicable
Blocks are resident in either modelspace or paperspace (note that they are blocks too) and can be accessed via the blocks collection of your drawing object. The simplistic answer is:

Sub Countblock()
MsgBox "There are " & ThisDrawing.Blocks.Count & " in this drawnig", vbCritical

End Sub
0 Likes
Message 4 of 9

Anonymous
Not applicable
Simplistic enough to be useless. I'm sure the OP wanted the number of *block
insertions* in the drawing.

--
R. Robert Bell


wrote in message
news:[email protected]...
Blocks are resident in either modelspace or paperspace (note that they are
blocks too) and can be accessed via the blocks collection of your drawing
object. The simplistic answer is:

Sub Countblock()
MsgBox "There are " & ThisDrawing.Blocks.Count & " in this drawnig",
vbCritical

End Sub
0 Likes
Message 5 of 9

Anonymous
Not applicable
I understand your sarcasm Robert, it is VERY useless, the cout varible. I have yet to find a reasonable way to get the block inserts in a drawing without somehow writting a sub that iterates the intire block array comparing string id's. major pain!
0 Likes
Message 6 of 9

Anonymous
Not applicable
Hi

Pass this parameters of "INSERT" and "*" like this.

NumberofBlockInsertsinDrawing = SelectObjectsOnLayer (ssObjects, "INSERT",
"*")
'''''''''''''''''''''''''''' '''''''''''''''''''

Public Function SelectObjectsOnLayer(ssObs As AcadSelectionSet, spObjectType
As String, spLayer As String) As Long

On Error Resume Next

Dim FilterType(0 To 1) As Integer

Dim FilterData(0 To 1) As Variant

Dim sNumber As String

FilterType(0) = 0: FilterData(0) = spObjectType

FilterType(1) = 8: FilterData(1) = spLayer

' The line below will create an error if the SSET doesn't exist

' or delete it if it does exist.

' The ON Error will allow the program to continue and create the set

ThisDrawing.SelectionSets.Item("SSET").Delete

Set ssObs = ThisDrawing.SelectionSets.Add("SSET")

ssObs.Select acSelectionSetAll, , , FilterType, FilterData

SelectObjectsOnLayer = ssObs.Count

Exit Function


SOLErrorHandler:

Err.Clear

SelectObjectsOnLayer = 0

End Function ' SelectObjectsOnLayer()


--

Laurie Comerford
CADApps
www.cadapps.com.au



wrote in message news:[email protected]...
I understand your sarcasm Robert, it is VERY useless, the cout varible. I
have yet to find a reasonable way to get the block inserts in a drawing
without somehow writting a sub that iterates the intire block array
comparing string id's. major pain!
0 Likes
Message 7 of 9

fxcastil
Advocate
Advocate
see attached file
0 Likes
Message 8 of 9

Anonymous
Not applicable
Is sarcasm required in a public space where we are simply trying to help out?

There is no way to get inserted blocks without iterating through model or paper. It's very easy. Good luck.
0 Likes
Message 9 of 9

Anonymous
Not applicable
>There is no way to get inserted blocks without iterating through model or
>paper

What about the posts above you that mention using filters? You can also add
a specific filter for just paper or modelspace 'Block References'

--
gl - Paul
wrote in message
news:[email protected]...
Is sarcasm required in a public space where we are simply trying to help
out?
. It's very easy. Good luck.
0 Likes