Easy Way to Count Components in Sketchup

Counting Components

General discussion related to SketchUp

Counting Components

I have a model with a component that's repeated hundred of times (little LED lights). I need to figure out how many lights there are. I could could the instances, but there must be an easier way. Is there a utility that will count the number of a specific component in a model? -- Joel

0

|| Joel Metzger 3D Modeling
|| story-shorts.net - Animation with SU

User avatar
JoelM3DM

Posts: 178
Joined: Wed Dec 10, 2008 1:36 am
Location: Doylestown, PA US
Name: Joel Metzger
Operating system: Windows
SketchUp version: 2015
License type: Pro
SketchUp use: film and stage
Level of SketchUp: Intermediate


Re: Counting Components

Postby massimo » Fri May 07, 2010 12:16 pm

Joel, just right click-->entity info on your component. :)

1

User avatar
massimo

Posts: 2047
Joined: Thu Mar 19, 2009 10:52 am
Location: Italy
Name: Massimo Siracusa
Operating system: Windows
SketchUp version: 2014
License type: Pro
SketchUp use: other
Level of SketchUp: Intermediate


Re: Counting Components

Postby JoelM3DM » Fri May 07, 2010 12:28 pm

Oh!

0

|| Joel Metzger 3D Modeling
|| story-shorts.net - Animation with SU

User avatar
JoelM3DM

Posts: 178
Joined: Wed Dec 10, 2008 1:36 am
Location: Doylestown, PA US
Name: Joel Metzger
Operating system: Windows
SketchUp version: 2015
License type: Pro
SketchUp use: film and stage
Level of SketchUp: Intermediate


Re: Counting Components

Postby jgb » Sat May 08, 2010 9:40 pm

There can be a problem with the entity info count. The count is correct, but you may have copies on invisible layers, or, duplicate coincident copies that look as only 1, which is very difficult to find.
So if the count seems wrong, start hunting.

To correct coincident copies, you need to delete a suspect. If it disappears, hit [undo]. If it remains, it was a duplicate. Do it again. In my early drawings I have had as many as 7 instances coincident, due to my inexperience then.

One very difficult situation to fix is where you have multiple copies INSIDE the group or component envelope. The only way I know of fixing that is to open the group/comp and rebuild it line by line. Deleting co-incident lines does not always work, and this condition is a major cause of faces that do not form. You have endpoints that are very close together.

0

__________________
jgb

User avatar
jgb

Posts: 784
Joined: Sun Mar 23, 2008 10:52 pm
Location: Toronto, Canada.
Name: jgb
Operating system: Windows
SketchUp version: 2015
License type: Free/Make
SketchUp use: engineering and mechanical design
Level of SketchUp: Intermediate


Re: Counting Components

Postby Anssi » Tue May 11, 2010 6:21 pm

Another way is via Window>Model Info>Statistics. Selecting "Show nested components" will show the correct figure even if you have components nested within groups and other components. The report can even be copied from the window and pasted into Excel, for instance.

Anssi

0

securi adversus homines, securi adversus deos rem difficillimam adsecuti sunt, ut illis ne voto quidem opus esset

User avatar
Anssi

Posts: 1122
Joined: Mon Nov 12, 2007 8:56 pm
Location: Porvoo, Finland


Re: Counting Components

Postby Juantxo » Mon Feb 14, 2011 8:40 am

If you insert a group with an instance of a component inside, count_instaces method and ComponentDefinition.instances["instance"].length fails.

http://www.youtube.com/watch?v=kLAAAK2_APc

You need to enter inside the groups, then the number of instances is corrected.
¿Is there another way?

0

User avatar
Juantxo

Posts: 83
Joined: Wed Jul 28, 2010 3:40 pm
Location: Valencia
Name: Juantxo
Operating system: Windows
SketchUp version: 2014
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

  • Website

Re: Counting Components

Postby TIG » Mon Feb 14, 2011 10:29 am

Select one instance of the component in your model.
Paste this 'one-liner' into the Ruby Console - it should return the number of its instances correctly - including any 'nested' ones. Use the ideas to make a short script...

Code: Select all
p Sketchup.active_model.selection[0].definition.instances.length

An instance inside a definition only gets counted the once - so that requires you to then find the number of the container-instances using a similar technique, and simply multiply the numbers together... :geek:

1

TIG

User avatar
TIG
Global Moderator

Posts: 20229
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced


Re: Counting Components

Postby thomthom » Mon Feb 14, 2011 10:41 am

TIG wrote:Paste this 'one-liner' into the Ruby Console - it should return the number of its instances correctly - including any 'nested' ones.

No - it doesn't account for nested instances.

0

User avatar
thomthom
PluginStore Author
PluginStore Author

Posts: 19455
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2019
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced

  • Website

Re: Counting Components

Postby TIG » Mon Feb 14, 2011 11:11 am

thomthom wrote:

TIG wrote:Paste this 'one-liner' into the Ruby Console - it should return the number of its instances correctly - including any 'nested' ones.

No - it doesn't account for nested instances.

Well it does for me :?
Make a component and say 6 copies of it.
Make a component of say 2 of them - we now have 4 in the model and 2 inside a definition.
When I run the snippet - it returns 6... NOT 4 ?
If you copy the second component the reported figure is still 6 since there are 2 in its definition.
To get the total you need to count the number of instances which nest them...
I don't see what you are saying ? It does work ??
As I thought I explained the nested ones are only counted once and you need extra steps to count up their container instances too...

0

TIG

User avatar
TIG
Global Moderator

Posts: 20229
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced


Re: Counting Components

Postby thomthom » Mon Feb 14, 2011 11:21 am

TIG wrote:If you copy the second component the reported figure is still 6 since there are 2 in its definition.
To get the total you need to count the number of instances which nest them...
I don't see what you are saying ? It does work ??

That's what I meant - it doesn't return the total number of instance you can see in the model when one or more of its parents also have instances.
I guess it depends on what you expect.

0

User avatar
thomthom
PluginStore Author
PluginStore Author

Posts: 19455
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2019
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced

  • Website

Re: Counting Components

Postby Juantxo » Mon Feb 14, 2011 12:34 pm

In the video you can see 3 rectangles, but count_instaces only returns 1. If you click all the groups to edit them and then exit, count_instances returns the
rigth number, 3 rectangles. I think count_instances method has a bug. ¿What do you think?

0

User avatar
Juantxo

Posts: 83
Joined: Wed Jul 28, 2010 3:40 pm
Location: Valencia
Name: Juantxo
Operating system: Windows
SketchUp version: 2014
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

  • Website

Re: Counting Components

Postby thomthom » Mon Feb 14, 2011 12:40 pm

Juantxo wrote:In the video you can see 3 rectangles, but count_instaces only returns 1. If you click all the groups to edit them and then exit, count_instances returns the
rigth number, 3 rectangles. I think count_instances method has a bug. ¿What do you think?

No - it's not bug. It's as expected. When you copy a group you create an instance of that same group. Inernally in SU groups are like Component Instances but with the exception that when you edit (or open one) they are made unique.

In order to get the correct count you need to also count the instances of all the parents for each instance of the group you count.

0

User avatar
thomthom
PluginStore Author
PluginStore Author

Posts: 19455
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2019
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced

  • Website

Re: Counting Components

Postby Juantxo » Mon Feb 14, 2011 1:15 pm

I understand. You are the best

Thanks very much!

0

User avatar
Juantxo

Posts: 83
Joined: Wed Jul 28, 2010 3:40 pm
Location: Valencia
Name: Juantxo
Operating system: Windows
SketchUp version: 2014
License type: Pro
SketchUp use: engineering and mechanical design
Level of SketchUp: Advanced

  • Website

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Ad Machine
Robot

Posts: 2012

  • Website


Return to SketchUp Discussions

jimenezentrught.blogspot.com

Source: https://sketchucation.com/forums/viewtopic.php?f=15&t=28142

0 Response to "Easy Way to Count Components in Sketchup"

Enregistrer un commentaire

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel