Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression reading output of expression and misc questions regarding this

  • expression reading output of expression and misc questions regarding this

    Posted by Ross Klettke on December 18, 2012 at 5:49 pm

    I’ve always avoided using the output of one expression as an input into another expression, though I see that it is possible…

    Example:
    Layer 1, with an expression on its xPos: Math.sin(time)

    and Layer 2, with an expression on its xPos: thisComp.layer(“Layer 1”).transform.xPosition

    ——

    Is this sort of practice something that should be avoided or, if it is worthwhile in certain cases, are there any pitfalls to be aware of? Is there any way I can order the layers to speed up evaluation of the expressions? (Letting AE know that Layer 1 should be evaluated first and then Layer 2)

    Would putting this expression on Layer 2–
    thisComp.layer(“Layer 1”).transform.xPosition.valueAtTime(time – framesToTime(3));
    — cause any additional concerns?

    Additionally, let’s say that there are keyframes on Layer 1’s xPos — can Layer 3 access Layer 1’s xPos value before the expression’s output masked it? (the keyframe data and not the output of the expression on Layer 1’s xPos)

    ——

    If the above is okay, I imagine a cycle is still always a bad idea?

    Example:
    Layer 4, with an expression on its xPos: thisComp.layer(“Layer 5”).transform.xPosition * -1

    and Layer 5, with an expression on its xPos: Math.sin(time * 2) * 50 + thisComp.layer(“Layer 4”).transform.xPosition;

    ——

    Thanks!
    –Ross

    Ross Klettke replied 13 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 18, 2012 at 10:01 pm

    >Is this sort of practice something that should be avoided

    There could be a potential performance issue if you had a long chain of expressions where, for example, each expression references the same property in a previous layer. There are usually ways to avoid that.

    > can Layer 3 access Layer 1’s xPos value before the expression’s output masked it?

    Not directly. There is an obscure work around where Layer 1 can “publish” it’s pre-expression value in negative time like this:

    if (time < 0){
    valueAtTime(-time);
    }else{
    (regular expression goes here)
    }

    Then another layer could do something like this:

    thisComp.layer(“Layer 1”).transform.xPosition.valueAtTime(-time)

    Since there is no negative time zero, you may have to add special code to handle that.

    >I imagine a cycle is still always a bad idea?

    I think in best of circumstances the outcome may be unpredictable, so I’d avoid it.

    Dan

  • Ross Klettke

    December 18, 2012 at 10:06 pm

    Awesome, thanks Dan! And that “publish”-to-negative-time workaround is really interesting.

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