Auto Grid

Automatically arrange duplicated layers into a grid based on their layer index.

Expression Code

// Auto Grid
// Apply to Position
// Duplicate the layer to fill the grid

cols = 4;           // Number of columns
spacingX = 200;     // Horizontal spacing
spacingY = 200;     // Vertical spacing
startX = 200;       // Grid start X
startY = 200;       // Grid start Y

i = index - 1;
col = i % cols;
row = Math.floor(i / cols);

x = startX + col * spacingX;
y = startY + row * spacingY;

[x, y];
Apply to Position on a layer. Set your grid columns and spacing. Duplicate the layer — each copy automatically positions itself in the grid based on its layer index.