How to Find the Number of Instances of a Component in a File?


Hey Guys,

I’m trying to help a coworker figure out how to count the number of instances of a particular component. It’s a revit conversion so there are a ton in the file because it’s a large athletic facility. I have never done this before so I’m a little fuzzy and the components window would take a long time to load since there’s so many.

Is there a way to quickly spit out a value for the number of, say, Light#1, in a file?




Just select the component in question and the entity window will indicate the number of identical components.

Also consider using the outliner tray to view components.


To do it in code…
Open the Ruby Console.
Copy/Paste this code + enter.
It should print out the count for the named component definition.

name = "Light#1" # edit name as needed
puts("#{Sketchup.active_model.definitions[name].instances.length} instances of #{name}") rescue "No definition: \"#{name}\""


Thanks Guys. I have some new info. Apparently it’s not so much to count an existing component. She needs to place 700 instances of a particular component into the file. It’s also sporadic so she needs to be able to check the number periodically.

I’ll try the entity info thing real quick though.