Count / selection count
-
Hi guys, is there a way to count selected objects? For example: I have parking slots, (each slot is a component). When I select a part or the area containing these objects, an info feedback will return, something like "100 objects selected". For those familiar with CAD interface, it's the same found on command box.
Thanks!
-
right click on selection and select entity info which will open a window and at the top you will see how many you have selected.
-
If you want to extract the count of specific objects within a larger selection you need to filter the results.
A one-liner typed or copy+paste into the Ruby Console +<enter> can so this.
This example counts all instances of a component named 'parking' within a broader selection:c=0;Sketchup.active_model.selection.grep(Sketchup;;ComponentInstance).each{|i|c+=1 if i.definition.name=='parking'};p c;
If you have several to count en mass like 'Parking', 'parking#1', 'parking#2' etc use a regex test like
i.definition.name=~/^[Pp]arking/
to match more than one name...
If you want to count ALL instances of a given component [with selection] useputs(Sketchup.active_model.definitions['parking'].instances.length)
There are many possibilities ...
Advertisement