Skip to main content

Easy Bounce Scripting API

All functions of Easy Bounce Pro for After Effects can also be remote-executed from other scripts (note that this is not possible with the free version). It supports exactly the same functions as the build-in KBar-API, so please refer to the KBar API documentation for the documentation of all available functions.

Using the API is best explained with an example:

/*
This document explains how to remote-execute functions of Easy Bounce Pro
from other Ae scripts.
Note that Easy Bounce Free does not support scripting or KBar.

The API object used here has the same functions as the KBar API
(see https://mamoworld.com/article/easy-bounce-kbar-api)
*/

// let's get the API to do something with Easy Bounce.
// Pass a file object to EasyBounce.jsxbin as argument
// of the getEasyBounce() call
// if it is not in the same folder as this script.
// See definition of this function at the end of this file
var API = getEasyBounce();

// apply EasyBounce to the first two layers of the active comp
var myLayers = [app.project.activeItem.layer(1),app.project.activeItem.layer(2)];
API.applyBounce({
layerArray: myLayers,
workAreaOnly: false, // if true, only keyframes inside the workarea are processed
gravity: 50, // pass a value between 0 and 100 here, default 50
addSquash: true, // adds the bezier warp to squash at impacts; note that this might require to precompose
subframeAccuracy: false, // if true keyframes will be in-between frames
squashAmount : 50, // between 0 and 100, how much the layer will deform at impact
squashDuration : 50, // between 0 and 100, how long it takes after the impact to go back to normal shape
squashChaos : 0, // between 0 and 100, adds randomness to deformation at impact
preserveApexX: false, // if true the apex locations are NOT shifted left/right to improve the motion path

});

/*
This function creates the easyBounce object if it does not exist yet

If scriptFile is undefined, this function assumes that EasyBounce.jsxbin is
in the same folder as this script file. Otherwise, please pass a file object
for EasyBounce.jsxbin as scriptfile argument.
*/

function getEasyBounce(scriptFile){
if(typeof easyBounce == 'undefined'){
return executeEasyBounce(scriptFile);
}
return easyBounce;


function executeEasyBounce(scriptFile){
if(scriptFile === undefined){
scriptFile = getEasyBounceFromDefaultLocation();
}
if(!scriptFile.exists) throw new Error("could not find file "+scriptFile.fsName);
scriptFile.open("r");
var fileContents = scriptFile.read();
scriptFile.close();

// yes, this is a global variable.
// we use this kbar API to tell Easy Bounce that it should not show its user interface
// and return its API instead
kbar = { button:{argument:"getAPI"}};
// execute the file --> this should create the easyBounce object
var result = eval(fileContents);

// when Easy Bounce understands the button command, it will set it to undefined.
if(kbar.button !== undefined){
throw new Error("Easy Bounce didn't understand the getAPI action, is scriptFile pointing to another script?");
}
return result;
}

function getEasyBounceFromDefaultLocation(){
// get the folder where this script file is located
var myFolder = (new File($.fileName)).parent;
// find EasyBounce.jsxbin in the same folder
var scriptFile = new File(myFolder.fsName+"/EasyBounce.jsxbin");
return scriptFile;
}
}

What about licenses?

Of course, the API will only work if a proper Easy Bounce Pro license is installed (or if you are running Easy Bounce Pro in time limited trial). The API will not work with the free version of Easy Bounce.