Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
🫛 Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download
Top Level Component or Group
-
I am trying to detect a top level Component or Group from a nested one.
if ((obj.is_a? Sketchup;;ComponentInstance) || (obj.is_a? Sketchup;;Group) && (obj.parent.is_a? Sketchup;;Model)) popup.add_item(C2LAYSCENE) { # part_2_layer_command # } popup.add_item(C2SCNE) { # shopDrawingCommand # } end # Single part testThis test fails and when the user has selected a nested comp/grp I still show these commands.
Keith
-
@ktkoh said:
I am trying to detect a top level Component or Group from a nested one.
if ((obj.is_a? Sketchup;;ComponentInstance) || (obj.is_a? Sketchup;;Group) && > (obj.parent.is_a? Sketchup;;Model)) > popup.add_item(C2LAYSCENE) { > # > part_2_layer_command > # > } > popup.add_item(C2SCNE) { > # > shopDrawingCommand > # > } > end # Single part testThis test fails and when the user has selected a nested comp/grp I still show these commands.
Keith
You just need to put the '||' check inside parentheses
if (((obj.is_a? Sketchup;;ComponentInstance) || (obj.is_a? Sketchup;;Group)) && (obj.parent.is_a? Sketchup;;Model)) -
And it really should look like this:
if (obj.is_a?(Sketchup;;ComponentInstance) || obj.is_a?(Sketchup;;Group)) && obj.parent.is_a?(Sketchup;;Model) -
Thanks that worked and after seeing it correct it makes sence.
KeitH
Advertisement