Create several arrays of circles bound inside different closed curves

Hi, I’m trying to fit an array of circles inside a number of closed curves (without overflowing over the edges). The curves are given by a drawing.
I’m having trouble with culling the array. It’s either culling all the circles only to the first closed curve or intersecting all the circles with all the curves, which leaves some circles where they don’t belong.
I’ve attached the code I created.
I also seem to be having trouble correctly filling the boundaries with circles.

It would be very appreciated if someone could take a peek and direct me where I’m wrong.

7-segments.3dm (58.3 KB) micro (10.8 KB)

You rounded too much, see the replaced “Int” parameters with “Num”.

Then, “Square grid” components outputs a tree.
Your “InCurve” test was working with non-matching trees. Fixed with “Trim tree”.

Also, you can draw your circles after you find the proper centers, a little faster than making all the circles and then culling.

Changed the script so the center of the grid are in the center of the shape.

Other details inside.
micro (22.8 KB)

This is incredible!
Thank you so much.
I have a lot to learn still. Thank you!