Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions mix (add) 2 layers position information into one – script/expression

  • mix (add) 2 layers position information into one – script/expression

    Posted by Roei Tzoref on July 12, 2016 at 6:35 pm

    is there a script or an expression or a way to merge 2 layers into a third layer that will add the two position values together but in a way that the position remains unchanged? yes – as if I copy pasted both into a new layers. I got many many it’s very messy.

    TrackerViz only get’s me halfway there and it’s no good. it combines the layers and offsets the first layers motion to move smooth by information from the second and I just want to add.
    for example:
    I got one layer going from 5.5 (x,y) to 10.10(x,y) from 0:00-0:02
    other layer going from 15.5(x,y) to 25.5 (x,y) from 0:02-04:00
    and I want to combine the 2 into a new layer that goes
    5.5 to 10.10 to 15.5 to 25.5 from 0:00-04:00

    video example here:
    https://docs.google.com/uc?id=0B5wyUt17-tu2VDVBLTRtOXBMT0E

    Roei Tzoref replied 10 years, 1 month ago 2 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    July 12, 2016 at 7:40 pm

    You can’t create an new layer with an expression, but if the 3rd layer already existed, an expression like this might work:


    p1 = thisComp.layer("Shape Layer 1").position;
    p2 = thisComp.layer("Shape Layer 2").position;
    if (time > p1.key(p1.numKeys).time)
    p2
    else
    p1

    Dan

  • Roei Tzoref

    July 12, 2016 at 8:16 pm

    Dan you are a Saint and your place in expression heaven is assured.
    it works and now I will put it to the test for real.

    one more questions if you don’t mind:
    1. how can I make it 3 layers also, instead of 2

    thank you

  • Dan Ebberts

    July 12, 2016 at 8:45 pm

    To create a new layer, you’d need a script, which could then apply the expression.

    Dan

  • Roei Tzoref

    July 12, 2016 at 8:48 pm

    yes thank you. I created the layer myself. it works wonderful.
    I put two layer controls on it so I could have more control.
    what if I want a 3rd layer? i.e connect layer 1 + layer 2 + layer 3 to a layer that I will create
    p1
    p2
    p3
    ?

  • Roei Tzoref

    July 12, 2016 at 9:02 pm

    got a bit of a problem here. could I have that the mix will be adjusted to the layers duration?
    I have many layers and they end at different time so when I add the 3rd layer I have to manually adjust it to the duration of layer 2 or else it will be there when it shouldn’t. here how it looks:
    10291_layers.jpg.zip

  • Dan Ebberts

    July 12, 2016 at 9:47 pm

    I guess that would be like this:


    p1 = thisComp.layer("Shape Layer 1").position;
    p2 = thisComp.layer("Shape Layer 2").position;
    p3 = thisComp.layer("Shape Layer 2").position;
    if (time > p2.key(p2.numKeys).time)
    p3
    else if (time > p1.key(p1.numKeys).time)
    p2
    else
    p1

    Dan

  • Dan Ebberts

    July 12, 2016 at 9:50 pm

    You can’t affect the duration, but you could add an opacity expression that checks for the last keyframe of the last source layer:


    p2 = thisComp.layer("Shape Layer 2").position;
    if (time > p2.key(p2.numKeys).time)
    0
    else
    value

    Dan

  • Roei Tzoref

    July 12, 2016 at 10:08 pm

    works Marvelously. thank you this saved me hours and over heating my brain to do this manually.

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