sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Solved: need help with groups and their names

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 577 Views 2 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.
    • A Offline
      a4chitect
      last edited by a4chitect

      hello rubies, is there a way to select groups by their name?

      i want to be able to access the position of a specific group in the model and only know its name

      thanks

      (do you think that selecting all groups and checking each one in a loop is as good as it gets?)

      1 Reply Last reply Reply Quote 0
      • A Offline
        a4chitect
        last edited by

        found the solution myself, thanks for watching

        Sketchup.active_model.active_entities.find_all {|e| e.name=="Group Name"}
        
        1 Reply Last reply Reply Quote 0
        • fredo6F Offline
          fredo6
          last edited by

          You should check the type too (e.type == 'Group') as there may be other drawing elements with the same name

          1 Reply Last reply Reply Quote 0
          • A Offline
            a4chitect
            last edited by

            fredo please go into more detail, because this combination doesn't find the group

            Sketchup.active_model.active_entities.find_all {|e| e.class=="Sketchup;;Group" and e.name=="Group Name"}
            
            1 Reply Last reply Reply Quote 0
            • fredo6F Offline
              fredo6
              last edited by

              Sorry, I meant e.typename == 'Group'
              If you prefer to use class id, then you must NOT enclose it between quotes
              --> e.class == Sketchup::Group

              1 Reply Last reply Reply Quote 0
              • A Offline
                a4chitect
                last edited by

                fantastic - thanks!!!

                i guess that going through the basics of ruby in SU is inevitable, but doing mash-ups is so much fun 😄

                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