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