Rotate object in ruby script


Not sure if this is the right place and I have only a very limited knowledge on Ruby but here goes!

I want to use / modify Clark Bremer’s Rotate 90 extension to rotate single components around their component axis … unfortunately it seems to rotate around the bounding box axis

I think I have identified the code that does this but after browsing API coding my eyes are starting to water and my head hurts…

rp = #rotation point

I assume there is an equivalent line to rotate around a component axis instead of a bounding box,

PS, I did search for other extensions that might do a simple rotate 90 [for aligning doors, windows , furniture etc with a quick hot key selection] but all seemed overly elaborate.

Any help appreciated from all you talented extension developers…

I must be getting old, I seem to have the attention span of a 2 year old!


the bb knows where it is in the model and has 8 corners or a centre to choose from…

bounds.corner(0) is often the same thing as componentdefinition.insertion_point but not always…



As a CAD user and developer for over 40 years, I’ve observed what kinds of transforms and rotations are most frequently needed in design, All can be accomplished with the powerful bultin SketchUp tools for scale, rotate and move.
However there is trade off in user complexity.
So I developed the extension called 2DXY SlickMoves. It provides “one click” execution of the 13 moves most often needed.
For rotation of objects (components or groups): the most common need is for rotation about the object Z axis at its center, with a default of plus or minus 45 degrees.
See the overview video at
For more detail on rotation see the instruction video at following the 10 minute mark.


Thanks Barry,

Nice extension and I appreciate your approach, are you rotating around the bounding box centre or are you rotating around the objects z axis? . As you know the insertion point [component axis] often is in a specific location related to how that object is positioned in the design and it is not always the centre of the bounding box.

Maybe it is easier just to make it a dynamic component and use functions and click to rotate it around the axis. Thanks for your advice


Thanks John, doesn’t the component local axis know where it is in the SU model?

or is that only carried by BB parameters?


I do agree with Barry that usually Sketchup’s built in rotate tool is enough, but there may be some times when there’s no face to snap to which lets you set the rotation.

Try this:

def CB_R90.rotate90(sel, axis)
	ra = 90.degrees
	sel.each do |ent|
        rv = ent.transformation.zaxis if axis == "z"
        rv = ent.transformation.yaxis if axis == "y"
        rv = ent.transformation.xaxis if axis == "x"
        rp = ent.transformation.origin
	    ent.transform!(Geom::Transformation.rotation(rp, rv, ra))

I hope this is what you meant.


I like to refer to the real world. In reality a physical chair doesn’t have an “insertion point”. If it did, there is no way to tell where it is, so why think that you need it? (It might be anywhere depending on the whim of the chair builder.)
But as a designer I can look the chair and visualize it’s center. That’s the point I most often want to use at the Z axis for rotation.

As an architect, and because of the fact of gravity, I observe that its very rare that I ever need to rotate any real object about any axis other than the local Z.


A group or component_instance has a transformation:

That returns an origin - aka its insertion_point

Its transformation also has axes, so to find its zaxis vector use

Now perhaps use

ro=Geom::Transformation.rotation( ip, za, 45.degrees )

To rotate it centered on its insertion point, around its zaxis, by 45° etc


Thanks TIG,

I knew there must be a simple answer to a simple request…


Hi John,

I have removed that line :slight_smile:

Nevertheless, in some cases it is desirable to also rotate about a specific axis ,

in my case the insert point [component axis] and

after many years of experience I always try to put the insert point in a architecturally meaningful place

Barry has developed a really helpful plugin and I fully appreciate its value and ease of use.


You’re a legend…
Thank you so much…!!