Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Does a “layer time index” exist?

  • Does a “layer time index” exist?

    Posted by Anders Carlsson on January 24, 2011 at 11:31 pm

    In composition layers are easily acceseble with layer(index number). But is there a way to see “index” of layers as they appear in the timeline? For example, layer(6) could be the first layer to appear in the timeline, layer(2) the second layer etc. Is there a way to find out whish index number that corresponds to as layers appear in the timelinr?

    Dan Ebberts replied 15 years, 6 months ago 3 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    January 24, 2011 at 11:58 pm

    Not easily. You’d need to write a loop that checked each layer’s in point and sorted the results. What are you trying to do? There may be a better way to do it.

    Dan

  • Simon Björk

    January 25, 2011 at 9:08 am

    Hi Dan,

    I’m in this aswell. We’re trying to move each layer in the timeline back 50 frames. Except the first layer that appear in the timeline, that I only want to move 25 frames back. I thought I could find somehow what the first layer was by some kind of “time index”. Any ideas?

  • Dan Ebberts

    January 25, 2011 at 3:15 pm

    It sounds like you need a simple script that will make two passes through the comp’s layer stack, the first time looking for (and moving) the layer with the earliest in point, and a second time to move all the other layers.

    This would be pretty easy to do manually, so I assume you must have a bunch of these to do, is that correct?

    Dan

  • Simon Björk

    January 26, 2011 at 8:50 am

    Yeah, it can be a lot of layers and will take a lot of time to do manually. I have made a script that moves each layer 50 frames back. I guess I would loop through the time of each layer to find out which one that starts first so I can move that only 25 frames. Any idea how this would be done? My scripting skills are still pretty poor…

  • Dan Ebberts

    January 27, 2011 at 12:19 am

    Something like this:


    {
    var myComp = app.project.activeItem;
    var myIdx;
    var myLayer;
    var myMin = 999999;

    // find layer with earliest in point

    for (var i = 1; i <= myComp.numLayers; i++){
    if (myComp.layer(i).inPoint < myMin){
    myMin = myComp.layer(i).inPoint;
    myIdx = i;
    }
    }

    // myIdx now has the layer index of the layer with the earliest in point

    // now move all layers

    for (var i = 1; i <= myComp.numLayers; i++){
    myLayer = myComp.layer(i);
    if (i == myIdx){
    myLayer.startTime -= myComp.frameDuration*25;
    }else{
    myLayer.startTime -= myComp.frameDuration*50;
    }
    }
    }

    Dan

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