5
votes

Is it possible to save all my custom expressions inside an external .jsx file, so I can call them from inside my projects?

For example, let's say I have an expression I use a lot, that ties a puppet tool point to a null object's position. I know I can I transform that expression into a function that could take, say, two arguments, but can I save it into a custom library, so that I can easily re-use it inside the project?

Right now, I'm simply copying and pasting the same code from property to property, and I'm beginning to feel there is an alternative way to do this more efficiently.

Thanks in advance!

2

2 Answers

3
votes

I tested this with success, put this on top of your expression:

$.evalFile("/Users/myname/ae/functions.txt");

Then you can access whatever functions you have in your functions.txt file.

See here for more details: https://forums.creativecow.net/readpost/227/29337

The problem with this method is that you still need to include the extra line for each expression.

Anyway here is my complete setup, just in case: my expression is:

$.evalFile("/Users/myname/ae/functions.txt");

var p1  = thisComp.layer("Null 1").transform.position;
var p2  = thisComp.layer("Null 4").transform.position;
var p = p2 - p1;

printPosition(p)

And my functions.txt file contains the following:

function printPosition (p){
    return " " + parseInt(p[0]) + " : " + parseInt(p[1])
}
-1
votes

I don't think that is possible. But you can accomplish a lot by saving the expression as a preset (by dragging the actual layer property to the Effects & Presets window. Note than you can the apply a preset to several layers by selecting them and using the Animation->Apply Animation Preset function

Hope that helps a little.