Find Rotated Text Anchor point

Good Afternoon,

For our plugin I need to know the “top left” corner of a Text Object’s TextGeometry.

Normally this is easy because it is text.TextGeometry.Plane.Origin
It is also shown by Rhino as a White dot (I have labelled A in the screenshot below.

However if the text has been rotated Then the anchor point is no longer at the “top left” – instead it is at the “bottom left”.

How do I calculate the top left in these cases?

So far the closest I have got is

var start = text.TextGeometry.Plane.Origin - text.TextGeometry.Plane.YAxis * text.TextGeometry.TextHeight   * text.TextGeometry.DimensionScale
                                                             + text.TextGeometry.Plane.XAxis * text.TextGeometry.TextModelWidth;

Which produces the red arrows in the screenshot – as you can see the Text @ -135 degrees is not at B which is the point I am trying to find
text rotation.3dm (43.9 KB)

My example file is attached


My first thought is to rotate the text (copy) from it’s existing plane back to the world-xy plane. Then make your calculations and transform the results, from the world-xy plane back to the text’s original plane.

– Dale

Thank you @dale ,

I have found a work around by rotating the Rhino Object so that it has zero rotation - then calculating the BoundingBox so that I can compute the true Text Width and Height. I then rotate the Text back to where it was and proceed.

I believe the root problem here was that TextEntity does not override the TextModelWidth method from AnnotationBase in order to account for the text rotation - this causes erroneous text widths to be reported. Indeed the AnnotationBase method just returns the width of the bounding box which will be wrong if the text has any rotation. The diagram below demonstrates this - the TextModelWidth is the length of the Red line - the Arc is present to show where i think the length value is coming from - the width of the bounding box.

Is this something we can get fixed?


I’ll add something to RhinoCommon to make this easier.

– Dale

1 Like

Thank you @Dale, that sounds great!

RH-69094 is fixed in Rhino 7 Service Release 21

1 Like