Search code examples
rubysketchup

Ruby Sketchup-rotate 3d text


I have found a code to rotate 3d text, 90 degrees.

mod = Sketchup.active_model # Open model
ent = mod.entities # All entities in model
sel = mod.selection # Current selection
group = ent.add_group
group.entities.add_3d_text('Right', TextAlignLeft, 'Liberation',  true, false, 60.0, 0.0, 0, true, 1.0)
 tr = Geom::Transformation.rotation(ORIGIN,X_AXIS,90.degrees)
 group.transform!(tr) 

I want to rotate the text flat, not vertically.

Any variation to the code, does not transform the text the way I want. Please see the image for clarification, I just want to rotate the image flat.

-

enter image description here


Solution

  • I can not test, but I can suppose:

    • X_AXIS is the red line;
    • Y_AXIS is the green line;
    • Z_AXIS is the blue line.

    So, you could try this rotation tr = Geom::Transformation.rotation(ORIGIN,Z_AXIS,90.degrees).

    Since you are rotating around a straight line passing through the origin, you should add also a translation along Y_AXIS by the 3d_text length.