ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

expression to layout layers in a grid

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
criis daw
expression to layout layers in a grid
on Dec 16, 2010 at 10:53:00 pm

Hello 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 ........


Return to posts index

Dan Ebberts
Re: expression to layout layers in a grid
on Dec 16, 2010 at 11:34:46 pm

It 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



Return to posts index

criis daw
Re: expression to layout layers in a grid
on Dec 18, 2010 at 10:57:41 pm

thats 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



Return to posts index


Dan Ebberts
Re: expression to layout layers in a grid
on Dec 18, 2010 at 11:13:47 pm

Hmmm... 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



Return to posts index

criis daw
Re: expression to layout layers in a grid
on Dec 18, 2010 at 11:28:57 pm

well 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



Return to posts index

Santi Agustí
Re: expression to layout layers in a grid
on Jan 17, 2019 at 3:10:01 pm

Hi!
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!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]