Inverted Text - mirror - c#

I have an inverted text with the mirror command, I want to put it normal again but without moving it from the position where it is-

Ex. image

I want to put it “This is a prove” without move his center

Code C#

Hi @gustavo.uzcategui,

Are you using Rhino 5 or 6? RhinoCommon or C++?

– Dale

1 Like

Hi Dale,

Rhino 5, c#

Hi @gustavo.uzcategui,

How about this?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var go = new GetObject();
  go.SetCommandPrompt("Select text to flip");
  go.SetCustomGeometryFilter(TextObjectGeometryFilter);
  go.Get();
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  var obj_ref = go.Object(0);
  var text_obj = obj_ref.Object() as TextObject;
  if (null == text_obj)
    return Result.Failure;

  var bbox = text_obj.Geometry.GetBoundingBox(true);
  var p0 = (bbox.Corner(false, true, true) + bbox.Corner(true, true, true)) / 2.0;
  var p1 = (bbox.Corner(false, false, true) + bbox.Corner(true, false, true)) / 2.0;
  var plane = text_obj.TextGeometry.Plane;
  var dir = Vector3d.CrossProduct(p1 - p0, plane.Normal);
  var xform = Transform.Mirror(p0, dir);
  plane.Transform(xform);

  var text = text_obj.TextGeometry.Duplicate() as TextEntity;
  text.Plane = plane;

  doc.Objects.Replace(obj_ref, text);
  doc.Views.Redraw();

  return Result.Success;
}

private bool TextObjectGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex ci)
{
  return null != rhObject && null != rhObject as TextObject;
}

– Dale

Hi Dale, this idea is almost perfect, I explain you

This is the text after to do a mirror command,

image

After to execute your idea,
image
The text was put in normal sense, but tilt angle cannot be changed and it should remain so…,

image