# How to place objects in a grid pattern with geometry nodes?

I'm trying to place objects in a grid pattern but I don't want a regular grid where I set column and row count. Instead of column and row I want to set the column and object count and if the count of objects is greater than the columns then it should automatically create a new row. Like in the picture there is a column count of 4 and object count of 9 when objects are greater than 4 it should place objects on a new row and when greater than 8 place on a new row and this should go on indefinitely. I believe it's possible to make something like this with the Grid geometry node but I don't know how. Maybe if I create a grid and make it 4 columns x 1000 rows and then only fill some of the grid cells based on the object count.

Here's a Geometry Nodes setup you can use where you have the Number of Objects and the Number of Columns you can adjust.

Divide the number of your objects by the number of columns.

Round this value up, then you get the number of rows.

The size of the grid results from the number of columns, rows and the given width of an object.

After you have created your grid, use the node Instance on Points.

However, pass a selection that contains the number of objects as the highest index.

Sorry, it didn't occur to me until after I made this post that it's actually largely identical to @HarryMcKenzie's.

Update

Here's another technique I came up with to go along with it:

Instead of using a grid as a base here, I just duplicate the given object and move its position with a little logic.

(Blender 3.2)

• Hey no problem! your solution is definitely better because it uses lesser nodes! You're the geo nodes expert :D Aug 17 at 9:01
• @HarryMcKenzie Thank you for your praise, I really appreciate it coming from you ;-) Aug 17 at 9:05
• <3 btw I was surprised that you're able to directly use index. in my case the index was not as ordered as in your case that's why I needed to position the instances with some additional math. what is going on XD Aug 17 at 9:11
• @HarryMcKenzie This is because you created your grid in the other direction. The indices of a grid always run along the Y-axis first (That's why I rotate the whole grid again by $90°$ at the end). Aug 17 at 9:22
• aaahhhh cool thank you! Aug 17 at 9:36