@tig said:

You can only really parse through entities 'collections': model.entities/model.active_entities and group.entities/definition.entities AND model.selection...

However, once you have a collected set from that, you can parse that set to find just the things on a certain layer, with a certain material etc...

Recently the use of 'grep' has been found to speed up entity parsing significantly, I recommend you try it...
So to find all groups in a selection use:
gps=model.selection.grep(Sketchup::Group)
Now 'gps' is an array of all groups in the current selection.
To find every selected group that's assigned layer 'XXX' use
xxx=[]; gps.each{|gp| xxx << gp if gp.layer.name=='XXX' }

If you want to find absolutely everything in the model using that layer, then:
gps=model.entities.grep(Sketchup::Group)
and process 'gps'...

To get matches within a group use:
gps=group.entities.grep(Sketchup::Group)
and process 'gps'...

To find everything in the model using a certain layer try:
xxx=[]; model.entities.each{|e| xxx << e if e.layer.name=='XXX' }

There are several alternative methods, like 'collect', but here I just show you make an empty array 'xxx=[]' and then we add to it using 'push' [<<] when we get a match...

Hello TIG,

This is once again very helpful. I think I understand your examples to experiment a bit and report back what I develop using this information.