Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Layers in a grid need to change the spacing between them

  • Layers in a grid need to change the spacing between them

    Posted by Riccardo Sinti on October 12, 2012 at 6:11 pm

    I have many layers laid out in a grid using a script. IS there an expression I can add to them, linked to a slider, so that I can change the distance between all the layers?
    thanks

    Dan Ebberts replied 13 years, 11 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    October 12, 2012 at 6:36 pm

    The expression would need to know where its layer is in the grid. I think I would let the expression control the grid spacing. You’d have a null named “controls” on the bottom of the layer stack with a Point Control named “Origin” to control the position of the upper-left element of the grid, a slider named “Horiz Spacing” to control the horizontal spacing, one named “Vert Spacing” for vertical spacing, and another named “Number of Columns” to control the number of columns. Then each layer participating in the grid (starting with layer 1) would have this expression:

    L = thisComp.layer(“controls”);
    origin = thisComp.layer(“controls”).effect(“Origin”)(“Point”);
    hSpace = thisComp.layer(“controls”).effect(“Horiz Spacing”)(“Slider”);
    vSpace = thisComp.layer(“controls”).effect(“Vert Spacing”)(“Slider”);
    nCols = thisComp.layer(“controls”).effect(“Number of Columns”)(“Slider”);

    n = Math.round(nCols);
    col = (index-1)%n;
    row = Math.floor((index-1)/n);
    origin + [col*hSpace,row*vSpace]

    Dan

  • Dan Ebberts

    October 12, 2012 at 6:57 pm

    Oops. That last line should be:

    L.toComp(origin) + [col*hSpace,row*vSpace]

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy