# After Effects Grid maker

I was messing about with expressions in After Effects a while ago and this week I saw two people online talking about something similar to this, so I thought I'd post the expressions here...

Basically, you start with one layer in a comp, then add these expressions to position and to scale. Then when you duplicate that layer, say 9 times, you get a grid of 3 x 3 to fit your comp size. Then you'd just replace the footage in each layer as needed.

**Position expression;**

*NumberAcross = Math.ceil(Math.sqrt(thisComp.numLayers));*

*W = thisComp.width/NumberAcross;*

*H = thisComp.height/NumberAcross;*

*gridPos = index ;*

*col = gridPos % (NumberAcross+0.0001) ;*

*row = Math.ceil(1/(NumberAcross/gridPos));*

*xPos = (thisComp.width/NumberAcross)*(col-1);*

*yPos = (thisComp.height/NumberAcross)*(row-1);*

*[(xPos+W/2) ,(yPos+H/2)]*

**Scale expression;**

NumberAcross = Math.ceil(Math.sqrt(thisComp.numLayers));

xSize = (thisComp.width/width)*100/NumberAcross;

ySize = (thisComp.height/height)*100/NumberAcross;

[xSize,ySize]

Then duplicate the item 4 times, 9 times, keep on duplicating

Let me know if it works! Seems to...