Tranformation move AND rotate

I am trying to move my component instance. Basically I have a vertical square ( x standing on the red line at [0,0,0]… I want to move that square to [,, 0]. Then push it on its side so that it is flat on the z plane. The corners of the square should now be [1000,1000.0],[1000,2000,0],[2000,2000,0] and [2000,1000,0].

Is there a way to do this in 1 step? And if not, how do I do it in multiple steps. Here is what I have tried:

#move the object…
targetPoint =,, 0)
Sketchup.active_model.selection[0].transformation =
#The object is where I want it. Now I want to push it onto its side
vector =,0,0)
degreesToRotate = 90.degrees
Sketchup.active_model.selection[0].transformation = Geom::Transformation.rotation(point,vector,degreesToRotate)
#Now the object is flat but its z value is and its x value is 0???

I have tried various combinations of the above code doing the rotation first then the move. I have tried using 0,0,0 as the roation point after moving. And anything else I could think of. I can never get the square laying flat at x=1000, y=1000, z=0

Any help would be greatly appreciated. Thanks!

Hi Johno,
You need to make a compound transformation.
When you do something like Sketchup.active_model.selection[0].transformation = ... you are just setting the transformation relative to the original position, so the second transformation overrides the first.

If you do:

trans_rot = Geom::Transformation.rotation(point,vector,degreesToRotate)
trans_move =


Sketchup.active_model.selection[0].transformation = trans_move * trans_rot

or, perhaps better:

Sketchup.active_model.selection[0].transform!(trans_move * trans_rot)

the transformations should be combined.
Tip: The order of the transformations matters!


@achidave made an edit before I completed below. Kind of a duplicate now.

According to the API, the “transformation=” method is used to set the transformation of this component instance." (The API reference can be terse.) That method replaces the existing transformation with the argument you are applying. If you call it multiple times with the same argument, you just keep setting the component instance’s internal transformation to the same value. If you want to use your transformation incrementally and apply it to the entity’s existing transformation, use the “transform!” method.

If you want to apply a series of transformations, like say transform ‘a’, ‘b’, and ‘c’, you can multiply them together like:

tr = a * b * c
Sketchup.active_model.selection[0].transform!( tr )

Now, for Sketchup’s way of handling transformation multiplication (column major). First ‘c’ is applied, then ‘b’, and finally ‘a’. Of course if you meant the other way around, then you need to reverse them. Transformation multiplication is not communitive, and the order is important.