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

Character Style Expressions not working

Explorer ,
Jul 02, 2024 Jul 02, 2024

I can't change any text properties of a text using the STYLE commands.
I must be using it totally wrong.
Why doesn't this work?

 

thisLayer.text.sourceText.setFontSize(50);

Whatever the syntax of the STYLE commands is, I find it completely incomprehensible.
None of the documentation on the internet works for me.
Even chatgpt gave up.
Is there anyone who can show in babysteps how to set omething correctly?
(please mark variables with a _ somewhere or else I get confused to see variables among the commandos)

TOPICS
Expressions , How to
216
Translate
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
Explorer ,
Jul 02, 2024 Jul 02, 2024

motiondeveloper .com says this:

This is partly because they break one of the unwritten "rules" of expressions, which is that expressions can only set the value for the property they're on.

I do not even understand that. I feel I'm so close but where are the cigars?

Translate
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
Community Expert ,
Jul 02, 2024 Jul 02, 2024

Try this:

style.setFontSize(50)

then this:

style.setFontSize(50).setText("new text")

That should help you get the hang of how it works.

 

Translate
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
Valorous Hero ,
Jul 03, 2024 Jul 03, 2024
LATEST

As Dan has suggested, you need to start your text styling with a "style" syntax. There are only TWO ways you will really use te style syntax - (1) Reference another Text Layer's Style (2) Reference the Current Text Layer's Style.

You use "style" when referencing the Current Text Layer. When referencing Another Text Layer's Style, you MUST reference that layer and its style - like this -

textStyleFromAnotherLayer = thisComp.layer("HeaderText").text.sourceText.style;

IMPORTANT to take note you have to reference the other layer's text.sourceText.style attribute, in full.

When referencing the Current Text Layer's Style, you do not have to reference text.sourceText UNLESS you want to reference it by changing its text string and this is usually done before declaring the style statement/code.

So, in your case, all that is required is - 

style.setFontSize(50) 

HTH


Very Advanced After Effects Training | Adaptive & Responsive Toolkits | Intelligent Design Assets (IDAs) | MoGraph Design System DEV
Translate
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