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

    Changing transformation variables

    Scheduled Pinned Locked Moved Developers' Forum
    13 Posts 4 Posters 340 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.
    • Chris FullmerC Offline
      Chris Fullmer
      last edited by

      I think there are many of us Matrix math newbies around here. But little by little we're comprehending some of this stuff. So don't be bashful.

      The problem you are running into is that a_transformation is NOT an array object. It is a transformation object. Run this:

      t = Geom;;Transformation.new([2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1])
      arr = [2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1]
      t_arr = t.to_a
      
      puts t.class
      puts arr.class
      puts t_arr.class
      

      "t" is class Geom::Transformation. "arr" is class Array. It just so happens that transformation objects contain data that can be output to look like an array, but they are not actually arrays at all. To retrieve their array, or present their data in array form, use the .to_a as I did in the example. So to change a transformation array element, you have to get the transformation, turn it into an array. Adjust the elements on that array. Then turn that array back into a transformation object. Then apply that transformation to your object. It might look like this:

      ` gc = Sketchup.active_model.selection[0]
      t_exist = gc.transformation.to_a
      t_exist[12] = 0
      t_exist[13] = 0
      t_exist[14] = 0

      t_new = Geom::Transformation.new(t_exist)
      gc.transformation = t_new`

      That code works when you have an group/component selected and then run the code in jim's web console. It will move your component to 0,0,0 and keep it's scale and rotation.

      Hope that gets things sorted out a little,

      Chris

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

      1 Reply Last reply Reply Quote 0
      • honoluludesktopH Offline
        honoluludesktop
        last edited by

        You guys are too fast for me today. I just made another mistaken post, failed to edit it, and then had to deleted it.

        What I tried, which the SUCF server failed to accomodate was to edit my post, while deleting it on another page. So I could retain a copy. Well "no can do", and both my pages crashed. Hope I didn't cause any confusion.

        Chris, thats neat stuff. Helps me to understand.

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

          Why is it that you want to poke values into slots in the transformation matrix? This should almost never be necessary.

          Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

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

            @martinrinehart said:

            Why is it that you want to poke values into slots in the transformation matrix? This should almost never be necessary.

            It is a quick way to 'drop' stuff to z=0...
            tra=object.transformation.to_a tra[14]=0.0 object.transformation=tra
            Do this inside a loop of all selected groups for example and they are all set onto the 'ground'...
            ❓

            TIG

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

              Its a quick way to move to a given point, if you don't want to find the vector to that point from the current point. I think it is also necessary to skew a somponent, since there is no skew command built into the API.

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

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

                @chris fullmer said:

                Its a quick way to move to a given point ...

                Quicker than move!()?

                Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

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

                  .move! will reset the scale and rotation of a component. So its not useful the way it is implemented. You have to first make a transformation object that includes the components scale and rotation, then replace its x,y,z values by hand. THen apply that transformation object to the group using .move! if you want to use the move method safely.

                  Try it out, if you have an animnation working using the .move! method. Just scale the component first, then run your animation on it and you will see it resets it's scale and rotation.

                  It is possible to workaround, and that is why the transformation matrix must be edited by hand.

                  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
                    MartinRinehart
                    last edited by

                    @chris fullmer said:

                    .move! will reset the scale and rotation of a component.

                    You are right. I still want to hear from Hawaii, though. Suspect that he might have overlooked a method.

                    Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                    1 Reply Last reply Reply Quote 0
                    • honoluludesktopH Offline
                      honoluludesktop
                      last edited by

                      Hi Martin, I originally posted an application that did some simple transformations, and became interested in the subject. As you know I am a beginner at all of this and while experimenting, I tried to change some values just to see how my components would behaved, failed to do so, and asked for help 😳

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

                        @honoluludesktop said:

                        Hi Martin, I originally posted an application that did some simple transformations, and became interested in the subject. As you know I am a beginner at all of this and while experimenting, I tried to change some values just to see how my components would behaved, failed to do so, and asked for help

                        Fine. I was afraid you overlooked available ways of getting stuff moved / rotated / scaled. I know I did when I started fiddling.

                        Author, Edges to Rubies - The Complete SketchUp Tutorial at http://www.MartinRinehart.com/models/tutorial.

                        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