Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to read Marker from any Null layer – is this possible.

  • Expression to read Marker from any Null layer – is this possible.

    Posted by Pablo Beckett on August 30, 2022 at 6:54 pm

    Is it possible to read the Marker time from any Null layer regardless of the layers name.

    Essentially I’d like to have a control layer which will iterate through every layer within a comp and if the layer has a marker on it it will trigger an expression, much the same as the ‘Opacity Flash – layer markers’ preset but for any layer which has a marker.

    I don’t want to have to point the expression to a specific layer or multiple layers, the only condition required it the layer(s) have markers.

    I imagine the starting point for this would be a ‘For Loop’ but I’m not sure.

    Many thanks in advance…

    Pablo Beckett replied 4 years ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 30, 2022 at 9:21 pm

    Probably something close to this:

    tMin = null;
    for ( i = 1; i <= thisComp.numLayers; i++){
    if (i == index) continue;
    m = thisComp.layer(i).marker;
    if (m.numKeys == 0) continue;
    n = m.nearestKey(time).index;
    if (time < m.key(n).time) n--;
    if (n > 0){
    t = time - m.key(n).time;
    if (tMin == null){
    tMin = t;
    }else{
    tMin = Math.min(tMin,t);
    }
    }
    }
    tMin == null ? 0 : tMin
  • Dan Ebberts

    August 30, 2022 at 11:48 pm

    I forgot to mention, as-is, you could use this to drive a time-remapped animation. If you wanted to use it to drive some other animated property, you’d probably want to change the last line to:

    valueAtTime(tMin == null ? 0 : tMin)
  • Pablo Beckett

    August 31, 2022 at 9:43 am

    Amazing, thanks Dan. Works like a charm.

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