Sketchup::Model#drawing_element_visible? will not accept leaf of type Group
Sketchup::Model#drawing_element_visible? throws an error when the leaf of an array representing an instance path is a Sketchup::Group
mod = Sketchup.active_model
group = mod.entities.add_group
mod.drawing_element_visible?([group])
throws
Leaf must be a type of Sketchup::Drawingelement
Please reference Developer's RubyAPI forum topic Drawingelement#visible? seems to return inconsistent results
SketchUp Pro 2022 Windows 10
RELATED: Attempts to create a new InstancePath object with it's class constructor also fail to create a valid instance path when a group is the leaf.
I also see this on SU2021.
We can only get a valid path if the leaf is a primitive.
Logged as: SKEXT-3342
Issue 764 Workaround
Avoid calling the Sketchup::Model#drawing_element_visible? method upon groups and instances by using a conditional expression (whilst this issue remains unfixed) ...
def self.is_any_object_or_geometry_hidden?(entities, path = [])
#
entities.any? { |entity|
entity_path = path + [entity]
if entity.respond_to?(:definition)
break true if is_any_object_or_geometry_hidden?(
entity.definition.entities, entity_path
)
else
break true if !entity.model.drawing_element_visible?(entity_path)
end
#
false # default return for the block
}
#
end
Unfortunately, there appears to not be an easy workaround when the entity is an Sketchup::Image object.
it will not also accept leaf of type ComponentInstance
This issue is fixed as part of release SU2026.0, hence closing.