api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Sketchup::Model#drawing_element_visible? will not accept leaf of type Group

Open SnowyEgret opened this issue 3 years ago • 5 comments

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

SnowyEgret avatar Feb 02 '22 03:02 SnowyEgret

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.

DanRathbun avatar Feb 02 '22 15:02 DanRathbun

Logged as: SKEXT-3342

sketchupbot avatar Feb 14 '22 07:02 sketchupbot

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

DanRathbun avatar Oct 01 '22 19:10 DanRathbun

Unfortunately, there appears to not be an easy workaround when the entity is an Sketchup::Image object.

DanRathbun avatar Oct 01 '22 19:10 DanRathbun

it will not also accept leaf of type ComponentInstance

tomboul26 avatar Aug 25 '24 00:08 tomboul26

This issue is fixed as part of release SU2026.0, hence closing.

kalpana-ghodeswar avatar Dec 01 '25 14:12 kalpana-ghodeswar