Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Creating Dynamic Labels: Finding the current time of child comp

  • Creating Dynamic Labels: Finding the current time of child comp

  • Chris Orcfilm

    May 31, 2020 at 1:26 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

  • Robert Müller

    June 2, 2020 at 1:56 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;

  • Chris Orcfilm

    June 6, 2020 at 11:35 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

  • Robert Müller

    June 8, 2020 at 8:56 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;

Viewing 1 - 4 of 4 posts

Log in to reply.

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