sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    How to move a group?

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 231 Views 4 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.
    • M Offline
      Mcdull
      last edited by

      i want to move a selected group,and select the group with the code

       model = Sketchup.active_model
            entities = model.entities
         selectgroup = model.selection
         select_entity = selectgroup[0]
      

      how to move it to other location?

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        Use a Geom::Transformation - either .new to a point or .translation by a vector...
        http://code.google.com/apis/sketchup/docs/ourdoc/transformation.html

        TIG

        1 Reply Last reply Reply Quote 0
        • J Offline
          jessejames
          last edited by

          @mcdull said:

          i want to move a selected group,and select the group with the code

           model = Sketchup.active_model
          >       entities = model.entities
          >    selectgroup = model.selection
          >    select_entity = selectgroup[0]
          

          how to move it to other location?

          You are really creating more alias than you need. Actually you could do this script with just one line. If your never going to call an alias more than once why waste the CPU cycles?

          
          Sketchup.active_model.selection[0].transform!(Geom;;Transformation.translation([0,0,50]))
          

          ...but you may want to popup a dialog if the user forgot to select something or the selected "something" is not a group or component, or you may want the user to input an amount to move etc..! The script rolling is left as an exercise for the reader πŸ˜‰

          Always sleep with a loaded gun under your pillow!

          1 Reply Last reply Reply Quote 0
          • M Offline
            Mcdull
            last edited by

            @jessejames said:

            @mcdull said:

            i want to move a selected group,and select the group with the code

             model = Sketchup.active_model
            > >       entities = model.entities
            > >    selectgroup = model.selection
            > >    select_entity = selectgroup[0]
            

            how to move it to other location?

            You are really creating more alias than you need. Actually you could do this script with just one line. If your never going to call an alias more than once why waste the CPU cycles?

            
            > Sketchup.active_model.selection[0].transform!(Geom;;Transformation.translation([0,0,50]))
            

            ...but you may want to popup a dialog if the user forgot to select something or the selected "something" is not a group or component, or you may want the user to input an amount to move etc..! The script rolling is left as an exercise for the reader πŸ˜‰

            i have tried this method

            Sketchup.active_model.selection[0].move!
            

            before,i want to the group move from the boundingbox center the other point,and then this point turn to be the boundingbox center of the group's bounding box.according the above method,the group move form one corner edge to the point,and that target point turn to be the corner,not the center...

            1 Reply Last reply Reply Quote 0
            • Chris FullmerC Offline
              Chris Fullmer
              last edited by

              the move! method moves it only by the vector you provide, it dooes not care about boundinb boxes and points. It just uses a direction and length (vector). So what you need to look at is how you are creating your vector. Try finding the point that is the center of your box. Then find the point you want to move to. Then find the vector from one point to the other. Then use that vector to do your move. Then it will move the correct amount and direction.

              Show more of your code, specifically the part where you are finding the vector, to get more precise feedback,

              Chris

              Lately you've been tan, suspicious for the winter.
              All my Plugins I've written

              1 Reply Last reply Reply Quote 0
              • M Offline
                Mcdull
                last edited by

                thank u,i have got it...

                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