Finding corners of reference text on Rhino

I would like to generate a box around texts on my grasshopper script (not bounding box as some texts are tilted). So would like to obtain two points (diagonal) of texts then use rectangle 2pts to generate a box. Note that these texts are referenced texts on Rhino (from an imported AutoCAD file).

I managed to obtain a corner by using Python - rs.TextObjectPoint(i) which does not necessarily corresponds to fix position of each text (some are bottom left, some are top left etc.)

How shall I approach this? Thanks in advance.

Use bounding box with a rotated ‘P’ (Plane) input that matches the angle of the text.

@Joseph_Oster Thanks for the suggestion. I am quite new to this - how shall I obtain the angle of the text?

Ah, well, there’s the rub. If you’re lucky, it’s 30, 45 or 60 degrees, otherwise… You can trial and error plane rotation to find the bounding box with the smallest area. The following is an attempt to demonstrate that but it doesn’t work as well as I’d like and I’m out of patience.

The Crv param represents a bit of text at an arbitrary angle: (10.7 KB)

Thank you - I will give it a try.

minimal BBox should do the same job but I can’t make it work? (R5) And though the basic idea of what I posted above is very simple, getting meaningful angle values instead of their complement is much harder than it should be. I may try it again later.

If you are using python, you could use TextObjectPlane, and get the angle from there.

This could be useful too:


I put only a little more effort into trying to interpret rotation angle consistently before realizing that we don’t really need the angle at all, just the minimal bounding box. This simplification, along with checking only ±45 degrees instead of ±90 degrees, might have consequences later such as reversed UV dimensions? Would be helpful for you to post some examples internalized as GH please, rather than R6 .3dm file.

The ‘precision’ slider here has the effect of increasing resolution beyond the default one degree increments. A value of two will be half a degree, three will be 1/3rd degree, ten will be 1/10th degree of precision. (14.5 KB)

It can be clustered this way:

rotate_bbox_2019Nov8b (12.5 KB) (DEPRECATED! see below)

P.S. OOPS! Had to fix two issues with the cluster:

  1. Don’t assume ‘World XZ’ as the plane of rotation, use Plane Fit (PlFit) instead.
  2. Handle multiple ‘G’ inputs by using Shift Paths (PShift) instead of flatten. (17.8 KB)

Note that this whole idea assumes a “Flat Box”. With a more generalized 3D geometry, it is likely to fail at finding the minimal bounding box.

Later… I found that with just one more change, this cluster now handles 3D objects just as well as flat geometry. Replaced Disc with DeBrep and SubSet: (17.3 KB) (FAIL)

On second thought, this works only because I’m using a “well formed box” as input. Arbitrary geometry that is more complex will likely fail. :thinking:

@Adam_M I tried TextObjectPlane, but didn’t get what I want. The bounding box does not necessary surround the text. The forum however helps.

Thank you so much for your help.
Bounding box formed are like these

The planes obtained TextObjectPlane

The TextObjectPoint

Some points are not at bottom left

Try this. It may not be the most efficient method. (3.0 KB)

Please observe recommendation #3 on this list:

3. Attach minimal versions of all the relevant files
If you have a gh file you have a question about, attach it to the post. Do not expect that people will recreate a file based on a screen-shot because that’s a lot of pointless work. It’s also a good idea to remove everything non-essential from a gh file. You can use the Internalise Data menu option to cut everything to the left of a parameter:

If you are referencing curves or breps or meshes from Rhino, you can also internalise them so you won’t have to post a 3dm file as well as a gh file. If you’re unsure whether all the relevant data is internal to the gh file, try opening it in an empty Rhino. Does it work? Good. No? You’ll need to internalise more.

1 Like
  1. Solution exception:unable to convert 8b6f18a4-d721-413f-b7bd-3b61514ab9da into geometry


Strange, seems to work fine here in R6. I’m not really sure how to make it R5 compatible.

Do you have a Rhino file that hasn’t been posted here? How can these IDs be meaningful without any geometry?


Oh…Sorry, it would have probably been helpful if I had explained that part. Oops . You can select text from Rhino using the usual right click, set one or multiple method.

1 Like

Apologies, I wouldn’t be able to upload the entire rhino geometry (due to confidentiality). - I appreciate your advice and will take that on board. I will try to see if I can internalise it.

I don’t want or need “the entire rhino geometry”. Just a few samples of the texts you are referring to at various arbitrary angles. Is this concept really so difficult to grasp? Because a lot of people make the same excuse and it just doesn’t hold water.

But don’t bother now on my account, I’m done. @Adam_M’s solution appears to work very well.

Thanks @Adam_M, it works.

1 Like

Sorry @Joseph_Oster . Thanks for your input.