Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Calculate an expression value only once?

  • Calculate an expression value only once?

    Posted by Christopher Rieke on December 5, 2010 at 1:39 am

    Hello there,
    I am currently trying to setup a production kit for some OnTopGraphics. I am using an expression to determine the width of a text layer. In the end it should work that some text is entered and a mask will move to the end of the text layer. This works fine so far. But I realized that it takes really long to render this sequence because the text layer expression is calculating for every single frame even though the text stays the same (and also the width).
    I was wondering if there is a way to calculate this value once and reuse it in the other frames of the composition (like a global value)

    Any help or advice is appreciated…

    Thank you!

    in theory something like this:

    if
    (textwidth == undefined) {calculation stuff...;}
    [textwidth]

    Kevin Camp replied 15 years, 5 months ago 3 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    December 5, 2010 at 5:24 am

    You can’t pass values from one frame to the next, so if you set it up so that expression only calculates at the first frame, for example, on the other frames the value will be undefined and the expression will break.

    Dan

  • Christopher Rieke

    December 5, 2010 at 1:10 pm

    ok.
    i was suspecting this.
    Thanks for your reply and confirmation.

  • Kevin Camp

    December 6, 2010 at 7:51 pm

    i’ve never tried this, but it seems like it might work…

    how about you calculate only on the first frame and then use just that value for the remaining frames.

    you would need to calculate the width value to something like a slider control, then have the mask pull that value at the first frame.

    the slider expression might look like this:

    if (time>0) value else {calculation}

    and your mask’s position something like this:

    effect("Slider Control")("Slider").valueAtTime(0)

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Dan Ebberts

    December 6, 2010 at 7:59 pm

    I don’t think that saves you anything. The mask expression will still cause the slider expression to do the calculation for frame 0 on every frame.

    Dan

  • Christopher Rieke

    December 6, 2010 at 8:25 pm

    I just created a workaround. I calculated the width in an additional textlayer-text-source. so i have the result on screen and insert it manually into a third textlayer. this one will be used for the final rendering. it’s quite basic but good enough for me! 🙂
    thanks again for the support and the replys!

    chris

  • Kevin Camp

    December 8, 2010 at 4:23 pm

    i’m sure dan is correct about my idea… on every frame, one expression is just telling the other expression to re-evaluate at the first frame.

    another option would be to use ‘convert expression to keyframes’ from animation>keyframe assistant. this would ‘bake’ calculated value for every frame and disable the expression.

    you’d need to re-enable the expression if you made changes that would effect the values.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

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