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

    Given a x,y,z location to move a selected group help! solved

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 2 Posters 228 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.
    • dukejazzD Offline
      dukejazz
      last edited by dukejazz

      Is there a way in ruby code, given a x,y,z location to move a selected group directly to that location?
      Need help for my scale upgrade, best I can do is a iteration.

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

        @dukejazz said:

        Is there a way in ruby code, given a x,y,z location to move a selected group directly to that location?
        Need help for my scale upgrade, best I can do is a iteration.

        mod = Sketchup.active_model
        ent = mod.entities
        sel = mod.selection
        
        if sel.first.class==Sketchup;;Group || sel.first.class==Sketchup;;ComponentInstance
         inp=inputbox(["X;","Y;","Z;"],[0,0,0],"Move Component/Group to")
         if inp
          x,y,z=inp;move_to=Geom;;Point3d.new(x.to_f,y.to_f,z.to_f)
          move_from=sel.first.transformation.origin;
          tr=Geom;;Transformation.translation(move_from.vector_to(move_to))
          sel.first.transform! tr
         end
        end
        
        

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

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • dukejazzD Offline
          dukejazz
          last edited by

          Thank you.
          I will give it a try πŸ˜„

          1 Reply Last reply Reply Quote 0
          • dukejazzD Offline
            dukejazz
            last edited by

            Thank you, Sdmitch for your help

            History
            v1.1 May 27
            -fix move iteration problems

            scaleGroupFloat_dj Ver 1.1
            Copyright 2012, May 27
            DukeJazz: James Cochran
            http://forums.sketchucation.com/viewtopic.php?f=323&t=45254&p=404860#p404860

            My final form

            #sents
            ss =Sketchup.active_model.selection
            if ss.empty? then
            UI.messagebox ("Please Select. a goup.");return
            end
            sents = [];ss.each{|e|sents.push(e)}

            #_API____Geom::move! new_transformation
            entity_group=Sketchup.active_model.active_entities.add_group(sents)
            Geom::Transformation.new [x1,y1,z1]
            entity_group.move!(Geom::Transformation.new [x2,y2,z2])
            entity_group.explode

            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