-
Identifying Last Active Layer (Previous Layer in Time)
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)