Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Position any number of layers between two others

  • Position any number of layers between two others

    Posted by Jurij Magoga on May 18, 2009 at 8:55 am

    Hi, this is my first attempt to write an expression, i would like to get suggestions on how to improve it..

    I’ve found in AE help the expression to maintain one layer at a balanced distance between two other layers and i wanted it to work for any number of layers:


    x2 = thisComp.layer(“extr2”).transform.position[0];
    y2= thisComp.layer(“extr2”).transform.position[1];
    pos2 = thisComp.layer(“extr2”).transform.position;
    x1= thisComp.layer(“extr1”).transform.position[0];
    y1= thisComp.layer(“extr1”).transform.position[1];
    pos1= thisComp.layer(“extr1”).transform.position;

    if (x1 >= x2&&y1 >= y2){ (((pos1-pos2)*(index-1))/(thisComp.numLayers-2)+pos2)
    }else{
    if (x1 < x2&&y1 >= y2){ [(((x2-x1)*(index-1))/(thisComp.numLayers-2)+x1),(y1-((y1-y2)*(index-1))/(thisComp.numLayers-2))]
    }else{
    if (x1 < x2&&y1 < y2){ [(((x2-x1)*(index-1))/(thisComp.numLayers-2)+x1),(((y2-y1)*(index-1))/(thisComp.numLayers-2)+y1)] }else{ if (x1 > x2&&y1 < y2){ [(((x1-x2)*(index-1))/(thisComp.numLayers-2)+x2),(y2-((y2-y1)*(index-1))/(thisComp.numLayers-2))] } } } }

    This expression is for the position of the layers between the two layers(“extr2” and “extr1”).
    You can download the comp here:

    https://rapidshare.com/files/234297399/equidistanza_2_layer.aep.zip

    I will really appreciate any tip 🙂

    Jurij Magoga replied 17 years ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 18, 2009 at 1:22 pm

    This assumes that extr1 and extr2 are at the bottom of the layer stack:

    P1 = thisComp.layer(“extr1”).transform.position;
    P2 = thisComp.layer(“extr2”).transform.position;
    P1 + (P2 -P1)*index/(thisComp.numLayers-1)

    Dan

  • Jurij Magoga

    May 18, 2009 at 1:54 pm

    wow!
    Thank you so much..
    actually the hardest thing is to keep the expression simple.

    Thanks again,

    Jurij

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