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?
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.