Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Identifying Last Active Layer (Previous Layer in Time)

  • Identifying Last Active Layer (Previous Layer in Time)

    Posted by Royce Jacobs on February 22, 2022 at 1:59 pm

    Hey guys,

    So I’m automating a single text layer to animate in & out at the start of video clips. The text source displays a person’s name extracted from a split of the active video’s layer name. I’ve got everything working great, but now I also want it to skip any consecutive people’s names – like if one clip is split into multiple layers, I only want the name to animate in on the first instance in that consecutive set.

    I did make it so I can make a null layer called “Skip” and anything under it for its duration it will be skipped, but I’d like to automate skipping the consecutive duplicates because I’m importing long timelines from Premiere with lots of chopped up clips.

    In my for-loop I know I could save the current active layer’s inPoint and maybe somehow reference that to find the previous layer?…

    Here’s my working expression, it’s on the Start property of a Range Selector on the text’s animator, the same expression is on the End property – pic included for better readability (not sure why it’s double-spaced below)

    I would appreciate any help so much cause I’ve been going crosseyed trying to get it to do what I want…

    // Active Layer (top visible) Local Time Value (Starting after this layer)

    txt = '';

    skipUntil = '';

    localTime = '';

    startLayer = index + 1; // Where to start looking for Active Layer.

    for (j = startLayer; j <= thisComp.numLayers; j++){

    L = thisComp.layer(j);

    if (time >= L.inPoint && time < L.outPoint){ try{ txt = L.source.name; }catch(err1){ txt = L.name };};

    if (txt == 'Skip' && L.active) {skipUntil = L.outPoint; continue}; // Save how long 'Skip' layer is.

    if (time < skipUntil) continue ; // Skip until end of 'Skip' layer.

    if (txt.indexOf('█')<1) continue; // Skip if no block character (and therefore no name).

    if (! (L.hasVideo && L.active)) continue; // Skip layer if it's off or not visible.

    if (L.outPoint - L.inPoint < 1) continue; // If active layer is less than 1 second, skip it!

    if (time >= L.inPoint && time < L.outPoint){localTime = time - L.inPoint;} // Subtract Active Layer's in-point from time.

    };

    valueAtTime(localTime)

    Royce Jacobs replied 4 years, 5 months ago 1 Member · 1 Reply
  • 1 Reply
  • Royce Jacobs

    February 22, 2022 at 2:22 pm

    I meant to also include the Source Text expression:

    txt = '';

    startLayer = index + 1; // Where to start looking for Active Layer.

    for (j = startLayer; j <= thisComp.numLayers; j++){

    if (j == index) continue;

    L = thisComp.layer(j); if (! (L.hasVideo && L.active)) continue;

    if (time >= L.inPoint && time < L.outPoint){ try{ txt = L.source.name; }catch(err1){ txt = L.name } break;}

    };

    txt = txt.slice(txt.indexOf('█')+2);// Removing +2: 1 because index starts at 0, and 1 to remove the space after the block character.

    len = txt.length - 4;// Removing last 4 characters for dot & file extension.

    txt = txt.substr(0,len)

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