Fit rectangles inside surface?

Hi all. I do need to find a way to fit some rectangles (BB) inside of the corresponding planar surfaces (Top srf) by means of moving, scaling or rotating them without changing the XY proportions but I can’t find a proper way to achieve this goal.

I do tried a lot of thing without any good results. If somebody have any ideas on how this problem can be solved, please help.

Rectangles to fit inside Top srf.gh (12.1 KB)

Could this be a way?

Rectangles to fit inside Top srf a.gh (29.4 KB)

This is just a sample. It should be made automatically for a few hundreds different parts without my intervention. Otherwise I can move, scale and rotate by hand.

I’ll try it this way.

Rectangles to fit inside Top srf b.gh (23.6 KB)

Not exactly what I am looking for. This solution uses bounding box for the “Top Srf” but I do need to fit inside of the shape not inside of his bounding box. For this one of the shapes do have a hole in the middle, to find a way to fit the rectangle between the boundaries of the “Top srf“ shapes.

Your problem is not simple as you have rectangle that doesn’t fit in some shapes.

You can have the maximum circle(s) using that

This doesn’t seem to work

I tested Wordle but it is long.

perhaps OpenNest could be better ?