sketchucation logo sketchucation
    • Login
    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

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 644 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      ktkoh
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • sdmitchS Offline
        sdmitch
        last edited by

        @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))
        

        Nothing is worthless, it can always be used as a bad example.

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • Dan RathbunD Offline
          Dan Rathbun
          last edited by

          And it really should look like this:

          if (obj.is_a?(Sketchup;;ComponentInstance) || obj.is_a?(Sketchup;;Group)) &&
          obj.parent.is_a?(Sketchup;;Model)
          
          

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • K Offline
            ktkoh
            last edited by

            Thanks that worked and after seeing it correct it makes sence.

            KeitH

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Buy SketchPlus
            Buy SUbD
            Buy WrapR
            Buy eBook
            Buy Modelur
            Buy Vertex Tools
            Buy SketchCuisine
            Buy FormFonts

            Advertisement