Activity › Forums › Adobe After Effects Expressions › expression to layout layers in a grid
-
expression to layout layers in a grid
Posted by Criis Daw on December 16, 2010 at 10:53 pmHello everyone,
Can anyone please help me with an expression to lay out layers in a grid.
I would like to be able to determine the distance(x/y) between them.I have succeeded in creating a grid with expressions but would like to be able to then keyframe the individual layers.
I know i could just lay them out first and then keyframe , but i would like to have control over the layout in the grid, and now it puzzling me ……..
Santi Agustí replied 7 years, 3 months ago 3 Members · 5 Replies -
5 Replies
-
Dan Ebberts
December 16, 2010 at 11:34 pmIt will probably look something like this:
origin = [100,100]; // center of upper-left element
hDist = 100;
vDist = 100;
numCols = 5;myCol = (index-1)%numCols;
myRow = Math.floor((index-1)/numCols);origin + [myCol*hDist,myRow*vDist]
Dan
-
Criis Daw
December 18, 2010 at 10:57 pmthats great dan , thanks very much.
I added sliders to enable me to change the layout more simply.
As I wanted to also be able to animate each layer in the grid I added ‘+ value’ on the end and now I can layout all the layers and animate individually with key frames.
There is one thing that would make it absolutley perfect. when I come to animate the individual layers with position keyframes ,the points of the path start at the origin. It would be helpful if the position path points were at the same point as the anchor point. This is not essential as it is only to aid my visually when animating them layers.
Again , Many thanks
-
Dan Ebberts
December 18, 2010 at 11:13 pmHmmm… You could convert the expression to keyframes, then delete the keyframes and leave the expression disabled. That would leave the layer in its grid position and you could animate it from there.
Dan
-
Criis Daw
December 18, 2010 at 11:28 pmwell i can animate it by adding “+value” on the end of the expression.
It works just fine except that the position path is not where i would like it. Its not a problem , just slightly more tricky visually.
I would rather leave the expression active as the layout is not ‘fixed’ at this stage..
Thanks for the help
-
Santi Agustí
January 17, 2019 at 3:10 pmHi!
i’m trying to achieve the same with shape groups inside a shape layer, and as far as I could make it work with the X positions, I was not getting to work with the Y.
Once it reaches the 6th shape, it just goes to the 5th xposition side, and anything happens to Y (and the 6th shape doesn’t position below the 1st one etc)this is the code I’m using, taking yours as ref. (Its applied on the rectangle position, not the transform position of the group.)
origin= content ("cuad " + (parseInt(thisProperty.propertyGroup(3).name.split(" ")[1],10) - 1)).content("Rectangle Path 1").position;
myN=thisProperty.propertyGroup(2).propertyIndex-1;hDist = effect("xOffset")("Slider")
vDist = effect("yOffset")("Slider")
numCols = effect("Cols")("Slider");myCol = (myN)%numCols;
myRow = Math.floor((myN)/numCols);origin + [myCol*hDist,myRow*vDist]
any clue on this would be extra welcome, thanks!
Reply to this Discussion! Login or Sign Up