Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions if there’s a keyframe between these two markers…

  • if there’s a keyframe between these two markers…

    Posted by Bert Brown on July 23, 2010 at 1:43 pm

    How can I say:

    “if there’s a text keyframe between two comp markers on either side of the current time, display the source of the keyframe (for the duration between them)

    and if there is no keyframe, display nothing” ?

    I know how to acknowledge the nearest markers before and after the current time, but I don’t know how to acknowledge if a keyframe exists in the time between them.

    Bert Brown replied 15 years, 10 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    July 23, 2010 at 2:18 pm

    I think this works:


    n = 0;
    if (thisComp.marker.numKeys > 0){
    n = thisComp.marker.nearestKey(time).index;
    if (thisComp.marker.key(n).time > time){
    n--;
    }
    }
    txt = "";
    if (n > 0 && n < thisComp.marker.numKeys){
    if (thisProperty.numKeys > 0){
    t0 = thisComp.marker.key(n).time;
    t1 = thisComp.marker.key(n+1).time;
    for (i = 1; i <= thisProperty.numKeys; i++){
    t = thisProperty.key(i).time;
    if (t0 < t && t < t1){
    txt = thisProperty.valueAtTime(t);
    break;
    }
    }
    }
    }
    txt

    Dan

  • Bert Brown

    July 23, 2010 at 3:59 pm

    Holy cow. Seems to be working. I have the hardest time understanding For loops. I know when I need to use them, but they just don’t click.

    Thanks, Dan. I’m doing my best to wrap my head around this one. Seems like after your error prevention code, it’s actually not too bad.

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