Skip to main content
Known Participant
December 30, 2020
Question

is there script to increase duration of composition with included precomps and all layers inside

  • December 30, 2020
  • 2 replies
  • 280 views

is there script to increase duration of composition with included precomps and all layers inside

 

This topic has been closed for replies.

2 replies

Participating Frequently
January 9, 2021

I need similar for a script I was writing. Probably could be written better but I just pulled the function from a bigger script and patched it to work for you.

app.beginUndoGroup("Change Nested Comp Duration")

var comp = app.project. activeItem;
var mainCompDuration = comp.duration;
var mainCompFrameRate = comp.frameRate; 

changeDuration(comp);

function changeDuration(compToChange) {
    compToChange.duration = mainCompDuration;
    compToChange.frameRate = mainCompFrameRate; //Comment this out if you don't want frame rate to be changed
    for (var i = 1; i <= compToChange.layers.length; i++) {
        compToChange.layers[i].outPoint = mainCompDuration;
        if (compToChange.layers[i].source != null && compToChange.layers[i].source.typeName == "Composition") {
            changeDuration(compToChange.layers[i].source);
        }
    }
}

app.endUndoGroup()

Any questions please ask.

nadav_rock
Inspiring
December 30, 2020

If its all the comps in project you loop through project num items for each get num layers set comp length and layers end point. If it doesnt include all comps in project you do the same but you need a way when looping through project to distinguish the layers you want this to apply to like a prefix in their name

nadav_rock
Inspiring
December 30, 2020

Another way is for layer in main comp loop through project by name. If name doesnt match and comp type lengthen. If it does lengthen and get num layers inside and sub loop. This would require unique comp names to not apply to unrelated comps and precomps