Draw2dText - right justify



I’ve been looking for a method to right justify a 2d text element - is one available?

If not I hope that this could be included in a future release or upgrade – it would be very helpful, at least for some of the development work I’m doing.

Many thanks in advance.

(Dale Fugier) #2

Using Measure2dText, you should be able to calculate an offset to your text ends up right-justified.


Dale - I’ll take a look. A sincere thanks!



Are there any references for the method mentioned (ie. Measure2dText?) I quickly searched at rhino common but nothing appeared.

If it’s undocumented could you please provide a short example?

Sorry to ask - many thanks again for all of your help.

(Dale Fugier) #5

See of this is of any help.



the justification middleCenter does not work the same on building the source using rhinocommon of WIP 6


Has this been fixed?

(Dale Fugier) #8

Hi @HepChan,

Can you provide a simple example of what was working in V5 and that is now not working in the WIP?

– Dale


Hi @dale,

I create a table using lines (LineCurve) and then add text entities with MiddleCentre justification, and then pass all the geomtery together to create an instance object and place it in the layout view.
Rhino.Geometry.TextEntity te = new Rhino.Geometry.TextEntity();
te.Justification = TextJustification.MiddleCenter;

This is what I get in WIP:

This is how it is in working V5:

It is seen that the text is not in middle and center of the cell.

Also using doc.Objects.AddText with txtObj.TextGeometry.Justification = TextJustification.MiddleCenter; does not work.


Good illustration of your concern. How about posting the code that is responsible?


SampleDrawTable.cs (2.4 KB)

its a sample with a square and a text.
you will see the the position of the text in V5 and V6 displayed differently.

(Dale Fugier) #14

Hi @HepChan,

If you change

te.Justification = TextJustification.MiddleCenter;


te.TextHorizontalAlignment = TextHorizontalAlignment.Center;
te.TextVerticalAlignment = TextVerticalAlignment.Middle;

that command will work right.

– Dale


Is this a new way of doing things for V6, making it incompatible with V5, or a bug that needs to be fixed?