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.)
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:
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.
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.
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.
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.