Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Is it possible to have an expression linking keyframes to a time remapped layer?

  • Is it possible to have an expression linking keyframes to a time remapped layer?

    Posted by Daniel Haskett on November 16, 2007 at 6:08 pm

    Hi there

    Basically, say you have a layer, and you use time remapping and youve got your 2 keyframes that specify how much you want played….

    Ok and then if you have a load of keyframes on a layers rotation say, is it possible to link the time remapped layer to these rotation keyframes?

    so say, whenever the rotation is more than 5 degrees, it will trigger the beginning of the time remapped layer to play. and then it will play through. and then it will do this whenever the keyframe is above 5 degrees, once its played through…

    does this make sense?

    hopefully someone can help!

    thanks

    dan

    Brad Pickford replied 14 years, 6 months ago 3 Members · 11 Replies
  • 11 Replies
  • Dan Ebberts

    November 16, 2007 at 7:10 pm

    A time remapping expression like this should work:

    threshold = 5.0;

    rotVal = thisComp.layer(“Rotation Layer”).transform.rotation;

    above = false;
    frame = Math.round(time / thisComp.frameDuration);
    while (true){
    t = frame * thisComp.frameDuration;
    if (above){
    if (rotVal.valueAtTime(t) < threshold){ frame++; break; } }else if (rotVal.valueAtTime(t) >= threshold){
    above = true;
    }
    if (frame == 0){
    break;
    }
    frame–
    }
    if (! above){
    t = 0;
    }else{
    t = time – frame * thisComp.frameDuration;
    }

    Dan

  • Daniel Haskett

    November 16, 2007 at 7:40 pm

    hey dan

    thanks for your help, i just tried that now and it works well. however it only plays the time remapped layer once. is it possible so that whenever the layer rotates past 5 degrees it will play the time remapped layer again?

    thanks again

    dan

  • Daniel Haskett

    November 16, 2007 at 7:42 pm

    OOOPS! sorry please ignore that last post, i had the expression turned off so it was only playing once. just turned it on and it works great, thanks dan!

    dan

  • Daniel Haskett

    November 16, 2007 at 7:47 pm

    actually sorry dan, just one more thing…./

    is there a way so that when the rotation goes below 5 degrees, it will make the time remapped layer go back to its first frame?

    thanks again!

    dan

  • Dan Ebberts

    November 16, 2007 at 8:33 pm

    This should do it:

    threshold = 5.0;

    rotVal = thisComp.layer(“Rotation Layer”).transform.rotation;

    if (rotVal < threshold){ 0 }else { above = false; frame = Math.round(time / thisComp.frameDuration); while (true){ t = frame * thisComp.frameDuration; if (above){ if (rotVal.valueAtTime(t) < threshold){ frame++; break; } }else if (rotVal.valueAtTime(t) >= threshold){
    above = true;
    }
    if (frame == 0){
    break;
    }
    frame–
    }
    if (! above){
    0;
    }else{
    time – frame * thisComp.frameDuration;
    }
    }

    Dan

  • Daniel Haskett

    November 16, 2007 at 9:04 pm

    Thanks Dan, you’re a legend!

  • Brad Pickford

    October 10, 2011 at 8:54 am

    Hi Dan, I am trying to use this expression but I am getting the following error message…

    After Effects warning: Expected: )
    Expression disabled.

    Error occurred at line 6.
    Comp: ‘51_dad_isp_truck 02’
    Layer: 9 (‘spray’)
    Property: ‘Time Remap’

    Can you help?

    Thanks, Brad

  • Dan Ebberts

    October 10, 2011 at 5:45 pm

    Please post the expression that’s generating the error.

    Dan

  • Brad Pickford

    October 10, 2011 at 9:52 pm

    Here is the expression which is on the the Time Remap property…

    threshold = 5.0;

    rotVal = thisComp.layer("51_divider_horiz").transform.rotation;

    if (rotVal
    0
    }else {
    above = false;
    frame = Math.round(time / thisComp.frameDuration);
    while (true){
    t = frame * thisComp.frameDuration;
    if (above){
    if (rotVal.valueAtTime(t)
    frame++;
    break;
    }
    }else if (rotVal.valueAtTime(t) >= threshold){
    above = true;
    }
    if (frame == 0){
    break;
    }
    frame--
    }
    if (! above){
    0;
    }else{
    time - frame * thisComp.frameDuration;
    }
    }

  • Dan Ebberts

    October 10, 2011 at 10:04 pm

    It looks like you’ve only got part of the 5th line. Sometimes lines that contain a less-than character get mangled.

    Dan

Page 1 of 2

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