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 test
This 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 test
This 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