sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Undoing all transformations

    Scheduled Pinned Locked Moved Developers' Forum
    5 Posts 3 Posters 3.9k 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.
    • F Offline
      Frankn
      last edited by

      I'm pretty sure I've seen this before but I can't find the answer... so sorry in advanced if this is a repeat question.

      I'd like to remove all transformation for a given instance... so basically reverse what ever moves and rotations were done.

      I can get the transformation array,

      e.transformation.to_a
      

      and i tried setting everything back to 0 bu that didn't work...

      Thanks

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

        Maybe this?

        
        mod = Sketchup.active_model
        ent = mod.entities
        sel = mod.selection
        
        cmp=sel.first
        t=cmp.transformation.to_a
        t[0]=1;t[1]=0;t[2]=0;#t[3]=nil
        t[4]=0;t[5]=1;t[6]=0;#t[7]=nil
        t[8]=0;t[9]=0;t[10]=1;#t[11]=nil
        t[12]=0;t[13]=0;t[14]=0;#t[15]=nil
        cmp.transformation=cmp.transformation.set! t
        
        
        

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

        http://sdmitch.blogspot.com/

        1 Reply Last reply Reply Quote 0
        • F Offline
          Frankn
          last edited by

          sdmitch, just had a chance to try it out and it does work...

          Thanks!

          1 Reply Last reply Reply Quote 0
          • fredo6F Offline
            fredo6
            last edited by

            Also, to reset all transformations and puts the instance g at the origin, just use

            g.transformation = Geom::Transformation.new

            If you have a state before some transformations are made to the instance, you can save the state with ( clone is important)
            tr0 = g.transformation.clone

            Then, later, you can resume this state with
            g.transformation = tr0

            Note that the transformation of an instance corresponding to g.transformation is always in the context of its parent.

            1 Reply Last reply Reply Quote 0
            • F Offline
              Frankn
              last edited by

              Thanks for all that info fredo... It'll certainly come in handy

              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