ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Creating Dynamic Labels: Finding the current time of child comp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Chris Orcfilm
Creating Dynamic Labels: Finding the current time of child comp
on May 31, 2020 at 1:26:48 am

So, I created a text label in a parent comp to display the name of the comp, its current time and the name of the next (current) active layer on the timeline:
sLayer = "";
for (i = index+1; i <= thisComp.numLayers; i++){
L = thisComp.layer(i);
if (! (L.hasVideo && L.active && L.opacity > 0)) continue;
sLayer = L.name;
break;
}

"YOUR STUDIO NAME - " +thisComp.name+"|"+timeToCurrentFormat() + "\n"+ sLayer;


Works great, but I'd like to also display the internal current time of the child comp (L) layer after the child comp's name.

Probably overlooking the obvious but if anyone has any ideas?

At the very least, maybe the above code, as is, will help someone else.

Thanks for looking!

BC Canada


Return to posts index

Robert Müller
Re: Creating Dynamic Labels: Finding the current time of child comp
on Jun 2, 2020 at 1:56:49 pm

Hi Chris,
this should do the trick


sLayer = "";
for (i = index+1; i <= thisComp.numLayers; i++){
L = thisComp.layer(i);
if (! (L.hasVideo && L.active && L.opacity > 0)) continue;
sLayer = L.name;
sTime=timeToCurrentFormat(time-L.inPoint);
break;
}

"YOUR STUDIO NAME - " +thisComp.name+"|"+timeToCurrentFormat() + "\n"+ sLayer+"|"+sTime;


Return to posts index

Chris Orcfilm
Re: Creating Dynamic Labels: Finding the current time of child comp
on Jun 6, 2020 at 11:35:03 pm

Thanks Robert!

Definitely closer; of course this assumes the child comp start Timecode is 0:00:00:00 when it may actually be related to the timecode of the source film clip file instead.

L.displayStartTime won't work, as it is treating L as a layer instead of a (child) comp. so I came up with this:

sLayer = "";
sTime = "";
for (i = index+2; i <= thisComp.numLayers; i++){
L = thisComp.layer(i);
if (! (L.hasVideo && L.active && L.opacity > 0)) continue;
sLayer = L.name;
sTime = timeToCurrentFormat(comp(sLayer).displayStartTime+(time-L.inPoint));
break;
}

"YOUR STUDIO NAME - " +thisComp.name+"|"+timeToCurrentFormat() + "\n"+ sLayer + "|" + sTime ;

But that breaks if there is a layer that is a footage item and not a comp. For example if you have a locked cut for reference as your last layer item. Fixing it is as simple as making sure it's also a comp but figured there must be a way to determine in an expression if a layer is a CompItem:

if(L.source instanceof compItem){
sTime = timeToCurrentFormat(comp(sLayer).displayStartTime+(time-L.inPoint));
break;
}else{
sTime = timeToCurrentFormat(time-L.inPoint);
break;
}

but it appears that is extendScript not valid in an expression.

Seeing if the layer has numLayers (L.source.numLayers), ergo a comp, also errors for me.

Is there any quick way to determine if a layer is a precomp?

So Close!!

BC Canada


Return to posts index


Robert Müller
Re: Creating Dynamic Labels: Finding the current time of child comp
on Jun 8, 2020 at 8:56:28 am

Ok this should work for you:

sLayer = "";
for (i = index+1; i <= thisComp.numLayers; i++){
L = thisComp.layer(i);
if (! (L.hasVideo && L.active && L.opacity > 0)) continue;
sLayer = L.name;
sTime=timeToCurrentFormat(time-L.startTime);
break;
}

"YOUR STUDIO NAME - " +thisComp.name+"|"+timeToCurrentFormat() + "\n"+ sLayer+"|"+sTime;


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]