Skip to main content
ericsten
Inspiring
August 9, 2017
Answered

Master Expression for Multiple Layers

  • August 9, 2017
  • 1 reply
  • 10205 views

Working on a project that may have many hundreds of layers, and while many will have the same animations with time offsets etc I need to build it as an adjustable template.

Effectively I'm looking for a way to have many layers using the same expression from a single control layer so that if I want to make modifications to the expression I don't have to go through 100+ layers and re-paste the expression.

Ideal scenario would be to have an "Master Expressions" layer which has many properties with the applied expressions and then on all my other layers have them pull the expression code from the appropriate "Master Expressions" property. This way when I update the code in the "Master Expressions" it is applied globally across all linked layers.

I've attempted to use a Text Layer and input my expression in the "Source Text" parameter, but I have not found a way to pull the full text as applied expression for another layer.

Any ideas?

This topic has been closed for replies.
Correct answer Dan Ebberts

Say you have a text layer named "expression" with this text:

freq = 1;

amp = 100;

wiggle(freq,amp)

Then you could have this expression in another layer:

txt = thisComp.layer("expression").text.sourceText.value;

eval(txt)

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 9, 2017

Say you have a text layer named "expression" with this text:

freq = 1;

amp = 100;

wiggle(freq,amp)

Then you could have this expression in another layer:

txt = thisComp.layer("expression").text.sourceText.value;

eval(txt)

Dan

ericsten
ericstenAuthor
Inspiring
August 9, 2017

Thanks Dan!

You got me 99% there! One thing I found I needed to add around the expression in the text layer is triple quotes around the whole expression so that it behaved properly.

ie:

"""

freq = 1;

amp = 100;

wiggle(freq,amp)

"""