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

How to perform exponential scale in an AE script ?

Community Beginner ,
Jul 23, 2023 Jul 23, 2023

I am working on an ae script (jsx format) and would like to apply an exponential scale on a layer (same than in keyframe assistant). What is the command to use ?

Thanks !

TOPICS
Scripting
473
Translate
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

Community Expert , Jul 23, 2023 Jul 23, 2023

This seems to work:

var myComp = app.project.activeItem;
var myLayer = myComp.layer(1);
for (var i = 1; i <= myComp.numLayers; i++){
	myComp.layer(i).selected = false;
}
var myProp = myLayer.property("Scale");
myProp.setSelectedAtKey(1,true);
myProp.setSelectedAtKey(2,true);
app.executeCommand(app.findMenuCommandId("Exponential Scale"));
Translate
Community Expert ,
Jul 23, 2023 Jul 23, 2023

Once you set up the appropriate context (with just the scale keyframes selected) you could try:

app.executeCommand(app.findMenuCommandId("Exponential Scale"));
Translate
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 ,
Jul 23, 2023 Jul 23, 2023

Why would you even bother looking up the command? You can just as easily simply implement a Math.pow() or Math.exp() in your own code.

 

Mylenium

Translate
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 Beginner ,
Jul 23, 2023 Jul 23, 2023
LATEST

And what formula would you then use for, eg, de-scale from 3.4 to 2.2 ? Thanks

Translate
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 ,
Jul 23, 2023 Jul 23, 2023

This seems to work:

var myComp = app.project.activeItem;
var myLayer = myComp.layer(1);
for (var i = 1; i <= myComp.numLayers; i++){
	myComp.layer(i).selected = false;
}
var myProp = myLayer.property("Scale");
myProp.setSelectedAtKey(1,true);
myProp.setSelectedAtKey(2,true);
app.executeCommand(app.findMenuCommandId("Exponential Scale"));
Translate
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