is there a way I can count selected blocks

is there a way I can count selected blocks

ahawkinsPMFUA
Participant Participant
2,830 Views
14 Replies
Message 1 of 15

is there a way I can count selected blocks

ahawkinsPMFUA
Participant
Participant

ahawkinsPMFUA_0-1702312505214.png

Is there any way I can count selected blocks in autocad

0 Likes
2,831 Views
14 Replies
Replies (14)
Message 2 of 15

cadffm
Consultant
Consultant

Hi,

properties palette for your selected item CTRL+1

Helpful also function to select objects  selectsimilar 

qselect,ssx,filter

 

or command COUNT

 

Or dataextraction

 

 

Sebastian

0 Likes
Message 3 of 15

james_moore
Advocate
Advocate

I would use a quick LISP statement and see how many objects were selected.

(ssget "X" '((0 . "INSERT"))) will select all inserted blocks.

If you want specific inserts, select them by name using (ssget "X" '((2 . "name of block goes here")))

 

You can retrieve these using "P" in response to a "Select Objects:" prompt.  You might also try setting the selections to a variable for easy retrieval after other things have been selected.

(setq SET1 (ssget "X" '((0 . "INSERT"))))

(setq SET2 (ssget "X" '((2 . "put blockname here"))))

 

Of course this method is old, but very powerful.  You can do something like this using filters and just paying attention to the command line for feedback.

0 Likes
Message 4 of 15

pendean
Community Legend
Community Legend

@ahawkinsPMFUA wrote:

Is there any way I can count selected blocks in autocad


pendean_0-1702313023246.png

 

and/or

pendean_1-1702313077526.png

 

and

pendean_0-1702313131207.png

 

Message 5 of 15

Kent1Cooper
Consultant
Consultant

I don't understand what the image is supposed to convey.  But if you have some things selected [any kind(s) of things], put this in at the Command line, and it will return how many things:
(sslength (ssget "_I"))

Kent Cooper, AIA
Message 6 of 15

Michiel.Valcke
Advisor
Advisor

With Quick Select (QSE) you can select among all the blocks in your drawing based on any property you want. In the property palette you will see how many are selected at the top of your property palette.

MichielValcke_0-1702319533962.png


There also is an older command FILTER that will allow you to make a filter (you can base it on BlockName or another property) When you select-all afterwards it will only select the items that match your filter and it will tell you in the commandline how many were selected.

MichielValcke_1-1702319586893.png

 

And with the new command COUNT (as already shown by @pendean ) you can get an overview of all the different blocks in your drawing. You can also see similar geometries (which are presumed to be exploded versions of your blocks)

0 Likes
Message 7 of 15

james_moore
Advocate
Advocate

(sslength (ssget "_I"))

That is not a valid AutoLISP statement as far as I know.  I thought maybe I just hadn't learned that one yet, but it returned a bad argument type error when I tried it.

 

(sslength (ssget "X" '((0 . "INSERT")))) would work though.

 

You can do a lot with ssget, by changing the "X" and the (0 . "value") syntax appropriately.  It's the core selection function; mastering it is equivalent to all the other methods intended to simplify selecting objects with code.

 

0 Likes
Message 8 of 15

Michiel.Valcke
Advisor
Advisor

It is implied selection -> works like pickfirst, you want to have selected some items first. (and have the pickfirst enabled)

MichielValcke_0-1702324086450.pngMichielValcke_1-1702324098592.png

0 Likes
Message 9 of 15

leeminardi
Mentor
Mentor

@ahawkinsPMFUA wrote:

 

Is there any way I can count selected blocks in autocad


That's an open ended question that can be interpreted in a variety of ways as evident by the variety of answers.  Here are 2 more interpretations to the question and recommend answers:

Question 1.  I have a buncn of blocks selected how can I determine how many?

Answer 1.  The properties panel will show the number.

leeminardi_0-1702324238429.png

Or give a command like move and you will see the number then cancel the command.

leeminardi_1-1702324303074.png

 

Question 2,  I have a bunch of objects selected, some are blocks a sone are not.  How many of the slected objects are blocks?

Answer 2.  The properties panel will distinguish between blocks and other geometry.

leeminardi_2-1702324454369.png

 

 

 

lee.minardi
Message 10 of 15

Kent1Cooper
Consultant
Consultant

@james_moore wrote:

(sslength (ssget "_I"))

That is not a valid AutoLISP statement as far as I know.  ....


It is if there are selected objects at the time, as I described, and as @Michiel.Valcke has elaborated.  I assumed such a condition, from the wording of the topic heading.  But I agree that the original question is subject to various interpretations, so some clarity from the OP would help.

Kent Cooper, AIA
0 Likes
Message 11 of 15

james_moore
Advocate
Advocate

Gotcha, now I see it.  So I guess you could, for example, "SELECT" "ALL" and then enter (sslength (ssget "_I")) and it will return the number of INSERTs out of your selection set.

0 Likes
Message 12 of 15

Kent1Cooper
Consultant
Consultant

@james_moore wrote:

... I guess you could, for example, "SELECT" "ALL" and then enter (sslength (ssget "_I")) and it will return the number of INSERTs out of your selection set.


That would tell you how many objects of all kinds there are, not just Insert objects.

Kent Cooper, AIA
0 Likes
Message 13 of 15

james_moore
Advocate
Advocate

Ok, tried it, yep I see what you mean.

Now after all that, I fail to see where I might use this... but that's OK.  We don't all have to use the same methods. 😉 I'm unclear on the difference between (ssget "P") and (ssget "I").  I mean, if I have to have previously selected entities for either of these to work... I'll have to read the ssget options for the first time in a long, long time I guess.

0 Likes
Message 14 of 15

Kent1Cooper
Consultant
Consultant

@james_moore wrote:

.... I fail to see where I might use this... 


I agree -- I would just use the Properties palette's report if that's all I wanted to know.  But it seemed to be an answer to the question as asked, if I'm interpreting that correctly.

Kent Cooper, AIA
0 Likes
Message 15 of 15

james_moore
Advocate
Advocate

😁🤔  Yeah, we interpreted it differently.

I figured the blocks had to be selected before they could be counted, so that's where I started.  You figured he already had them selected and just wanted them counted.  My 1985-era method does both in one shot; but I admit it might not be so efficient if you're not a touch-typist.

Whatever works.

0 Likes