I am going to have tons of layers use the same expression, but I need to be able to edit the expression later without having to edit it for every layer. I also can't simply have each layer's property point to the original, because the expression needs to be evaluated for each layer relative to itself.

Is there a way I can have each layer expression simply point to and parse a text file? I could edit the text file so all layers expressions update. Or, if somehow I could put the expression on a null object and have each layer parse that expression for itself. Thanks for any help!

My workaround solution is to make a null object with a slider control for every single value that I may edit later, updating all layers, but this doesn't allow me to change the non-numerical information in the expression, such as adding parenthesis or other functions.

  • Sounds like a job for the extendscript toolkit.
    – stib
    Commented Jul 20, 2016 at 3:19
  • 1
    When I'm dealing with large numbers of layers using expressions the workaround I use is to give the layers that share expressions the same colour label. So then when you edit the expression you just copy, right-click>select label group, then paste.
    – stib
    Commented Jul 20, 2016 at 3:21

2 Answers 2


You can't put the expression on a null object, but you can use a text layer.

Following @bobtiki's eval() tip I tried using the source text of a text layer and running eval() on it. Initially I had no success, I was getting an "object of type TextProperty found where a Number, Array or Property is needed" error. But if I put something like a number on its own in the text layer and treated the source text like an array I could get it, I just wasn't able to access a whole string.

I was about to give up, then I remembered from doing extendscript scripting that you get the raw value of an AE property object using the javascript property .value*.

So after a bit of fiddling around with quotes and escaping (neither are needed, thank heavens) I got it to work.

TL;DR: Here is how you reference an expression that is written in a text layer's source, without having to save external files:

var theExpression = thisComp.layer("your text layer").text.sourceText.value;

And then you write the expression into the text layer, in this case called "your text layer". This is really cool! It even updates in real time as you're typing the expression!

Here's a comp with the position of the cyan layers being driven by the expression you see on the text layer. If I duplicate one of the cyan layers its position is calculated individually based on the random seed index, and if I change the expression, they all update!

enter image description here I'm stoked, this was the best question ever!

* this sentence sounds like gibberish I know. The problem is that AE layers' property's values are JavaScript objects, and as such they have JavaScript properties, and one of the AE property's value's JavaScript properties is the value property which represents the raw value of the AE property. And the value of the AE source text property is an object which must include formatting and whatnot, and so it is different to the text.sourceText.value value. Confused?

  • Using a text layer works PERFECTLY for what I am trying to accomplish! Thank you!
    – Ben Mora
    Commented Jul 21, 2016 at 15:03
  • Thanks. I've written it up as a post on my blog wp.me/p6MMUE-3K </shamelessselfpromotion>
    – stib
    Commented Jul 23, 2016 at 3:32

Yes, since expressions are basically JavaScript, you can load and evaluate external source files. Unfortunately the location needs to be hard-coded, since (AFAIK) expressions do not have access to the path of your AE project, so it's rather brittle. For instance:

try {
    myPath = "~/Desktop/source.js";
} catch(err) {

Further explanation of how similar code works can be seen on the ProVideoCoalition site.

One further caveat is that the script is loaded and evaluated again for every frame that gets rendered. You might want to test how loading the script affects your render times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.