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

Expressions : accessing Text property (fontSize) from another layer

Participant ,
Nov 09, 2019 Nov 09, 2019

Copy link to clipboard

Copied

I'm trying to read the font size of one Text layer ("Base") to another Text layer ("Target").
When I use the following on the sourcetext of the Base layer, it returns the font size - as expected - in its own layer (of course) :

style.fontSize;

 However, when I try to read this property to the Target layer, by using the following on the sourcetext of layer Target, I keep getting an error "Cannot read property  'fontSize' of undefined".  I've tried various permutations of the syntax, but no luck.

// First try, no luck. Error.
"FontSize : " + thisComp.layer("Base").style.fontSize;

//Maybe it needs the sourceText property? Nope, no luck either. Error
"FontSize : " + thisComp.layer("Base").sourcetext.style.fontSize;

//Maybe I need to specify it's a property of Text? Hmm, that returns "undefined" but no error.
"FontSize : " + thisComp.layer("Base").text.sourceText.style.FontSize;

//What if it's a property of Text directly? Let's see ... Error. 
"FontSize : " + thisComp.layer("Base").text.style.FontSize;

  I'm running out of options here.

Sure, I could add a Controller Null layer with an expression Slider control, and then add this in the sourcetext of every layer that use that size, but just like BurgerKing : "I want it my way .." 😉

style.setFontSize(thisComp.layer("Null 1").effect("Null - Fontsize Control Slider")("Slider"));

 Is it a bug? Am I asking too much?
Anyone? Anyone? Bueller? Anyone?  😉

TOPICS
Error or problem , Expressions , How to

Views

6.5K

Translate

Translate

Report

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

Participant , Nov 19, 2019 Nov 19, 2019

Well, the answer to this problem is : "Peter, learn to READ more carefully!".
Looking back at my original post, I already had the correct syntax in there ... HOWEVER ... I should pay more attention to the camelBack capitalisation of the properties ... 'FontSize' is not the same as 'fontSize' ...
Now it works!

Screen Shot 2019-11-19 at 19.10.05.png

Votes

Translate

Translate
Valorous Hero ,
Nov 09, 2019 Nov 09, 2019

Copy link to clipboard

Copied

This should work. Apply this Expression to the sourceText property of your Target Text Layer.

 

a = thisComp.layer("Base").text.sourceText.style.fontSize;
b= style.setFontSize(a);

 

I think the expression is quite self-explanatory. More info here https://helpx.adobe.com/after-effects/using/expressions-text-properties.html

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Votes

Translate

Translate

Report

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
Participant ,
Nov 19, 2019 Nov 19, 2019

Copy link to clipboard

Copied

LATEST

Well, the answer to this problem is : "Peter, learn to READ more carefully!".
Looking back at my original post, I already had the correct syntax in there ... HOWEVER ... I should pay more attention to the camelBack capitalisation of the properties ... 'FontSize' is not the same as 'fontSize' ...
Now it works!

Screen Shot 2019-11-19 at 19.10.05.png

Votes

Translate

Translate

Report

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