Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Accesing composition layers position

  • Accesing composition layers position

    Posted by Tomas Bumbulevičius on June 3, 2012 at 10:00 pm

    Hello,

    I am trying to make an expression, which would take picture from composition “layer_1” and move it from one corner of the screen to another in main comp. 1st layer go to the next corner, 2nd layer start moving near first one, then third one starts.. coordinates are just optional.

    The reason why I am asking for help, is because I am not sure whether it is possible to do so as I want. In composition “layer_1” there are 4 layers with pictures, but no matter what layer index I put into layer(i), it still shows me the first one… So maybe layers length should be different, from marker to market… or what?

    Could someone give me a shot whether I am doing something wrong?

    Thanks.

    x1=width-width/9;
    y1=50;

    x2=50;
    y2=height-130;

    timeInterval = 90;
    startPosition = [x1,y1,0];
    endPosition = [x2,y2,0];

    for (i = 1; i <=comp("layer_1").numLayers; i++){
    comp("layer_1").layer(i).position;
    linear(time,0,0+framesToTime(timeInterval),startPosition,endPosition);
    }

    Tomas Bumbulevičius replied 13 years, 11 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    June 4, 2012 at 12:12 am

    It’s not exactly clear to me what you’re trying to do, and if you already know this, I apologize, but a single expression can only affect the property to which it is applied. It appears that you want one expression to affect multiple layers, but you’ll have to apply an expression to each layer.

    Dan

  • Tomas Bumbulevičius

    June 4, 2012 at 7:28 am

    This is why I was asking for help, because I was not sure whether if is possible at all to make it work.

    Here i will try to explain better:

    There is a composition “Layer_1”, which contains 4 layers. By writing this line (comp(“layer_1”).layer(i).position), I hoped that i can access each of compositions layer by index. Is it not possible? And the reason why Im doing this, is because I want pictures to slide from one corner of the screen to another in a period of time(chosen this method, because there can be not constant amount of pictures). For now I am trying to accomplish only this step, to do not make it too complex, but it might be that Im trying to do what is impossible.

    If this way is bad, could you try to suggest me another algorithm?

    Thanks.

  • Dan Ebberts

    June 4, 2012 at 3:25 pm

    >I hoped that i can access each of compositions layer by index. Is it not possible?

    You can access layers that way, you just can’t change anything. If you want to change something, the expression has to be on that layer’s property. You can, however, set up an expression to do something different, depending on its own layer index, so your expression could do something like this:

    w = thisComp.width;
    h = thisComp.height;

    p0 = [width/2,height/2];
    p1 = [w-width/2,height/2];
    p2 = [w-width/2,h-height/2];
    p3 = [width/2,h-height/2];

    startPos = [p0,p1,p2,p3];
    endPos = [p1,p2,p3,p0];
    myStartPos = startPos[index-1];
    myEndPos = endPos[index-1];
    ease(time,0,1.5,myStartPos,myEndPos)

    You would apply this to Position property of the first four layers in the comp, and it would cause each to move to a different corner.

    I hope that gets you headed in the right direction.

    Dan

  • Tomas Bumbulevičius

    June 5, 2012 at 12:20 pm

    “You can access layers that way, you just can’t change anything. If you want to change something, the expression has to be on that layer’s property”

    This is the key what I was trying to figure out. Your example is helpful too, thanks for the help!

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