Rotate object in ruby script

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))
	end	
end

I hope this is what you meant.

3 Likes