Copy link to clipboard
Copied
Is there any easy way to change the duration/framerate of a comp and all its contents?
Example
I've made a comp (A) that is 30 seconds long 30fps since making that I've made a new comp (B) that is 5 seconds 60fps now the default is this. If I then import a file.
newFile.importAs = ImportAsType.COMP_CROPPED_LAYERS;
newLayer = app.project.importFile(newFile);
into my comp A it will take the settings from comp B.
What I've tried
In my script I made a throwaway comp that copies the settings from the comp I'm importing to
app.project.items.addComp(mainCompName, mainCompWidth, mainCompHeight, 1, mainCompDuration, mainCompFrameRate);
in hope that it would then change the comp settings defaults for when I import the file. It does not.
Another thing I've tried is manually setting the comps duration and then for loop through all the layers to change the outpoints however if there is another comp in this comp I will have to have nesting loops which is fine but I wanted to know if there's an easier way before I write this loop.
newLayer.duration = mainCompDuration;
newLayer.frameRate = mainCompFrameRate;
for(i = 1; i <= newLayer.layers.length; i++){
newLayer.layers[i].outPoint = mainCompDuration;
}
Thank you for any help.
If anyone else comes across wanting to do something like this, this is the loop I used. There might be an easier way but I can't find it.
//What Comp
newComp = app.project.items[int];
//Run Function
changeDuration(newComp);
function changeDuration(compToChange){
//Change Comp duration and framerate
compToChange.duration = mainCompDuration;
compToChange.frameRate = mainCompFrameRate;
//Change layers outpoint
for(var i = 1; i <= compToChange.layers.lengt
...
Copy link to clipboard
Copied
Why not simply buy/ download one of the gazillion existing comp changer scripts from AEScripts.com? Typically the issue with nested comp is simply avoided/ resolved by basing any processing on selections, anyway. No need to reinvent the wheel.
Mylenium
Copy link to clipboard
Copied
I'm writing my own script to do other things and this was something I ran into whilst writing it. When I pass the scipt on to my team members I don't want them to also have to download more scripts with something I can easily write, just wondered if there was an easier way than a nested loop.
Copy link to clipboard
Copied
If anyone else comes across wanting to do something like this, this is the loop I used. There might be an easier way but I can't find it.
//What Comp
newComp = app.project.items[int];
//Run Function
changeDuration(newComp);
function changeDuration(compToChange){
//Change Comp duration and framerate
compToChange.duration = mainCompDuration;
compToChange.frameRate = mainCompFrameRate;
//Change layers outpoint
for(var i = 1; i <= compToChange.layers.length; i++){
compToChange.layers[i].outPoint = mainCompDuration;
//If layer is a comp restart the loop with that comp
if(compToChange.layers[i].source.typeName != "Composition"){
}else changeDuration(compToChange.layers[i].source);
}
}