Can I identify if component or groups contains nested components/groups?

I am performing some operations on component/group but I want to skip nested component/group if present inside it.
Regarding this I want identify that nested objects so that I can skip it.

Is there any functionality is available in Sketchup Ruby API where I can identify nested components/groups inside it ?

Any help would be appreciated. Thank you.

You can use the parent method.
Check if parent is group or component and skip it

You also can check definition entities and group entities to check if there are nested groups or components

Yes, it is easy:

Where instance is the group or component instance:

# Get the definition's entities collection for the instance:
ents = instance.definition.entities
# Iterate the definition's entities collection:
ents.each do |entity|
  # Skip any component or group instances:
  next if entity.respond_to?(:definition)
  # ... Act upon the other kinds of Drawingelements here ...
1 Like