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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement