Sketchup coding ruby : list all elements by layer

it is very easy to start using the code in skecthup : open your document, and go to menu / window / Ruby Console. Everything you type in that ruby console will have immediate effect on the current project. My first hello world exercise was puts "helloworld" , basic introduction to Ruby. Second exercise was to list all elements within each skecthup layer, which is a little more difficult because some elements exist on their own and others exist within a group. So, inspired by this very helpful forum answer I decided I'd list only elements belonging to a group, just because that involves filtering entities, first by group and then by layer :

model = Sketchup::active_model

model.layers.each {|layer|

     grps = model.entities.grep(Sketchup::Group) 
grps_on_layer_twan = grps.each {|grp|
  puts grp.entityID if ;

Of course there is more in real life than just listing entities by their name : this plugin will list all objects of a project visually, for example

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *