How to Pack a Defined Square into a Rectangle/Square

Hi, programmers on the world,

I need to do a grid in Grasshopper for one of my projects, ideally using this method but I am also open for different ways.
My idea is to make it as user-friendly as possible.
First, I want the user to define a shape, of how each cell of a grid will look like.
Then I want them to draw a rectangle/square and pack the defined shape (grid cells) in it.

My question is how to do this :thinking:?

Thank you very much for you interest and help,
Michalina

Please find my described code attached:
Grid.gh (10.0 KB)

Not sure from your post what you are after. What is the shape allowed to look like?
If it is just a square or rectangle, the containing box will have to be an equal number of squares/rectangles in width/height right? Simple division stuff, so I assume you need something else?
If it is just the rectangle in a rectangular containing box, you can use the rect. grid component

Grid_2020Mar4a
Grid_2020Mar4a.gh (14.3 KB)

P.S. There is an unused Square component at the top left of the canvas that should be disabled.

1 Like

Thanks!
I am new in this community so I don’t know as much rhino as most people do yet :innocent:
Even though it may seem easy for you, I couldn’t find it out.
I really appreciate the time you gave into the script.
You gave me exactly what I was looking for, you are a lifesaver :wink: .

Thanks, I mean it,
Michalina