• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Easy way to change duration/framerate to a comp and all contents

Explorer ,
May 25, 2020 May 25, 2020

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.

TOPICS
Scripting

Views

705

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 25, 2020 May 25, 2020

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
...

Votes

Translate

Translate
LEGEND ,
May 25, 2020 May 25, 2020

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 25, 2020 May 25, 2020

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 25, 2020 May 25, 2020

Copy link to clipboard

Copied

LATEST

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);
    } 
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines