Fit Bounding Rectangle Inside Closed Curve

Hi everyone,

I am engraving some text into certain pieces for CNC, or Laser Cutting.

I have the pieces and the text, as curves. What I need to achieve is to fit the text within the piece… Right now its placed based on centroids.
For simplification purposes a bounding rectangle can be used to replace the text curves.

My idea is to maybe search for an optimal position with Galapagos, and eventually if the bounding rectangle of the text is still outside the closed curve, then go progressively scaling the text until it fits. I dont think any kind rotation would be a good idea.

So basically I need to fit the text using Translation and Scaling only.

TextFitting.gh (78.4 KB)

Any ideas on where to start are greatly appreciated.
Shynn

Hey ShynnSup,

{if I understood your problem correctly} here’s a cheat that might help in the meantime given the nature of your parts…

NOTE: ran out of time for the third option, plus it might work better using actual searchable characters as opposed to text curves because character ‘E’ (example) becomes split into little lines which then cause duplicate bounding boxes for one ‘character’. Hope it makes sense.

TextFitting_EDIT01.gh (102.6 KB)

  • perhaps look into the OpenNest plug-in to attempt other strategies of ‘nesting’ your text curves into your boundary.

Here my go,
I reused an old script, far from perfect but seems to work



TextFitting_LD.gh (88.0 KB)

1 Like

Hello!

Thank you! Could you upload a wider image of the def though? I am missing some multiplications and move to point from Pufferfish!

I actually used openNest to accomodate the pieces and get the text as curves! But I am not sure if it has addiotional options for text fitting…

Hey Laurent! Thank you! I actually found that thread and tried to work with the script you provided there, but I couldn’t make it work as I intended.

This look great! Two things though.

  1. Two pieces in the left bottom corner seem to have lost their text.
  2. Could be made so that already fitting text isnt scaled? Maybe if bounding box already fits inside closed curve = true. And perfom a dispatch or cull pattern! Will try myself later.

ShynnSup,

I did not use ‘multiplications’ from any plug-in so that’s probably something else.

If you download and install the plug-in first (pufferfish) then load the definition you should be fine! If not let me know?

Mutliplications changed from R5 to R6. If you open a file in R5 which was created in R6 the component wont show up.

Got you, I’ll save a new file

don’t know what happened to ‘curve array’ component - grabbed another one in Rhino 5 but it doesn’t work for a reason I do not need to know as it does work on R6 :slight_smile: it doesn’t matter though as the primary ‘solution’ in that script isn’t that array

TextFitting_EDIT02_r5.gh (94.1 KB)

Hello
I think 2 pieces are missing because of the size of the grid I use change 40 to 20 and it could work.