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

Set defined number of keys at once with same length in correlation to composition length?

Explorer ,
Jun 22, 2015 Jun 22, 2015

Copy link to clipboard

Copied

My problem:

My composition is i.e. 10 seconds long.

In this time I would like to have 10 keys.

The value will be defined later.

In my example the solution is easy.

But is there a function where I can define a number of keys, this function looks for the length of the composition, divides the length with the number of keys, and places the keys like this, that every key has exactly the same duration?

TOPICS
Scripting

Views

423

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
LEGEND ,
Jun 22, 2015 Jun 22, 2015

Copy link to clipboard

Copied

It could be scripted or one of those already existing scripts might come in handy:

Keyframes - Automation - After Effects - aescripts + aeplugins - aescripts.com

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
Community Expert ,
Jun 23, 2015 Jun 23, 2015

Copy link to clipboard

Copied

Lasergod schrieb:

But is there a function where I can define a number of keys, this function looks for the length of the composition, divides the length with the number of keys, and places the keys like this, that every key has exactly the same duration?

There is no ready to use function for this, but you can access the duration of a comp with

comp.duration // inherited from AVItem

and you can set keyframes for properties with

property.setValuesAtTimes(timesArray,valuesArray);

Hence, you can write such a function yourself.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

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
Advocate ,
Jun 23, 2015 Jun 23, 2015

Copy link to clipboard

Copied

LATEST

This is a real basic setup that will add keys mathematically evenly to all selected properties that can vary over time, but not whole frame evenly. As in there could be a keyframe midway in a frame due to the math. More math would be needed to divide the keys on proper whole frames. It may get you started at least. Due to the non whole frame key locations you may get odd animation blips because of this, so use at your own risk.

var keyWin = new Window("dialog", "Type in desired key count.", undefined);

var et = keyWin.add("edittext", undefined, "");

et.alignment = ["fill", "top"];

var grp = keyWin.add("group", undefined);

grp.orientation = "row";

var go = grp.add("button", undefined, "Go");

go.onClick = function(){

     var myComp = app.project.activeItem;

     var compDur = myComp.duration;

     var frameDur = myComp.frameDuration;

     var maxFrames = (compDur / frameDur);

     var etVal = Number(et.text);

     var val = isNaN(etVal);

     if(val == true){

          alert("Please enter a number only");

     }else{

          if(maxFrames > etVal){

               var myProps = myComp.selectedProperties;

               var myPropsLen = myProps.length;

               var intervalVal, curProp;

               app.beginUndoGroup("Add keys");

                    for(var p=0; p<myPropsLen; p++){

                         curProp = myProps

;

                         if(curProp.canVaryOverTime == true){

                              intervalVal = compDur / etVal;

                              for(var k=0; k<etVal; k++){

                                   curProp.addKey(intervalVal*k);

                              }

                         }

                    }

               app.endUndoGroup();

          }else{

               alert("Error:\nThat many keys exceeds the current timeline max of " + maxFrames.toString() + " frames.\n\nPlease choose a value lower than " + maxFrames.toString() + ".");

          }

     }

};

var close = grp.add("button", undefined, "close");

close.onClick = function(){keyWin.close();};

keyWin.center();

keyWin.show();

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