How to get all text annotation objects?

Hi everyone,

Since Rhino doesn’t support RTL languages, I thought I’ll be trying to make a quick fix that could be a workaround for that issue.

Actually the situation in Rhino 5 was:

you write backwards in the text box.
you get it displayed in the correct direction on screen.
you get it in the correct direction in print.

The situation in Rhino 6 is different:

you write backwards in the text box.
you get it displayed in the correct direction on screen.
you get it backwards in print.

So as a “first remedy”, I tried to reverse all text objects characters for each text object before sending to print so it will print in the correct direction (could be undone right after print).

The second part could be recognizing that a text object has just been created and reverse its characters so it would be written in the correct direction and also be displayed in the correct direction on screen (and then reversed on wish by the command mentioned above right before print).

So I tried to get all the text objects so I could work with them but I didn’t manage to get them as an array, this is what I got so far, but I didn’t see there is a text property:

I’ve tried a few things already including this:

RhinoObject[] objs = doc.Objects.FindByObjectType(ObjectType.Annotation);

but I couldn’t see/set the text property. probably not the right way.

Thanks for your help,

Roy.

Hi @Roy,

How about this?

var rh_objects = doc.Objects.FindByObjectType(ObjectType.Annotation);
foreach (var rh_obj in rh_objects)
{
  var annotation_obj = rh_obj as AnnotationObjectBase;
  if (null != annotation_obj)
    RhinoApp.WriteLine(annotation_obj.DisplayText);
}

– Dale

DisplayText is read-only so to reverse the text you’d have to change the Geometry. Maybe like this:

        var g = annotation_obj.Geometry as Rhino.Geometry.TextEntity;
        if (g != null)
        {
          g.PlainText = new string(g.PlainText.ToCharArray().Reverse().ToArray());
          annotation_obj.CommitChanges();
        }

The problem with doing it this way is that any rtf formatting will be lost. Without looking into it I’m not sure how you’d reverse an rtf string.

Thank you @dale (good to talk to you again :slight_smile: ) and @Alain

Yes, I’ve noticed it’s read-only so I went in another route and managed to get it to work using textobject.

I’ve also tried your (slimmer) solution and it worked the same. it does remove rich formatting, it removes font data but keeps colors and size.

It should be fine for what people need it for, which it getting the words in the right direction on display/print. I’ll make a few commands and share this plugin when I’ll be done with it.

Thanks again,

Roy Z.