Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Batch Sequence Layers on Multiple Compositions from Project Panel

  • Batch Sequence Layers on Multiple Compositions from Project Panel

    Posted by Luke Theobald on July 31, 2024 at 9:52 pm

    Hello all,

    I’m hoping you can help me with this question. I am looking for a solution of how to sequence layers within multiple compositions at once. Perhaps via a script?

    Basically I want to be able to select many compositions in the project panel at once, hit a button, and they all automatically run the same process that Keyframe Assistant does to sequence their contained layers with no overlap.

    Does anyone have knowledge of how this could be achieved?

    Luke Theobald replied 1 year, 12 months ago 3 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    August 1, 2024 at 2:06 pm

    It seems like it should be pretty straightforward. Something like this maybe:

    var mySelection = app.project.selection;
    var myComp, delta;
    for (var i = 0; i < mySelection.length; i++){
    myComp = mySelection[i];
    if (! (myComp instanceof CompItem)) continue;
    for (var j = myComp.numLayers; j >1; j--){
    delta = myComp.layer(j).outPoint - myComp.layer(j-1).inPoint;
    myComp.layer(j-1).startTime +=delta;
    }
    }
  • Luke Theobald

    August 1, 2024 at 2:19 pm

    Fantastic Dan, thank you so much this is great! Just have one further question…

    It works like a charm as long as there are no locked layers in the compositions, if there are locked layers it gives an error after the first composition and doesn’t affect the following compositions selected in the project panel. Is there any way around this, for the script to ignore errors and keep running?

  • Dan Ebberts

    August 1, 2024 at 3:06 pm

    What should it do when it encounters a locked layer?

  • Luke Theobald

    August 1, 2024 at 3:17 pm

    Ideally, the script would ignore the locked layers. I am using this script to sequence certain (unlocked) layers in many compositions, but I want other layers (locked) within these same compositions to be unaffected by the layer sequencing process.

    Thanks for your help with this!

  • Dan Ebberts

    August 1, 2024 at 3:58 pm

    Try this:

    var mySelection = app.project.selection;
    var myComp, delta;
    for (var i = 0; i < mySelection.length; i++){
    myComp = mySelection[i];
    if (! (myComp instanceof CompItem)) continue;
    for (var j = myComp.numLayers; j >1; j--){
    if (myComp.layer(j).locked) continue;
    for (var k = j -1; k > 0; k--){
    if (myComp.layer(k).locked) continue;
    delta = myComp.layer(j).outPoint - myComp.layer(k).inPoint;
    myComp.layer(k).startTime +=delta;
    }
    }
    }
  • Luke Theobald

    August 1, 2024 at 4:04 pm

    This is perfect Dan! Thank you so much for your help. This will save me a ton of time.

  • Brie Clayton

    August 1, 2024 at 8:01 pm

    Thanks for this solve, Dan!

  • Dan Ebberts

    August 1, 2024 at 10:46 pm

    Actually, that last one isn’t quite right. This should be better:

    var mySelection = app.project.selection;
    var myComp, delta;
    for (var i = 0; i < mySelection.length; i++){
    myComp = mySelection[i];
    if (! (myComp instanceof CompItem)) continue;
    for (var j = myComp.numLayers; j >1; j--){
    if (myComp.layer(j).locked) continue;
    for (var k = j -1; k > 0; k--){
    if (myComp.layer(k).locked) continue;
    delta = myComp.layer(j).outPoint - myComp.layer(k).inPoint;
    myComp.layer(k).startTime +=delta;
    break;
    }
    }
    }
  • Luke Theobald

    August 2, 2024 at 2:31 pm

    I’ll swap this one in, thank you again Dan!

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