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

Expression to count number of lines in a text layer

Explorer ,
Sep 22, 2024 Sep 22, 2024

Hello!

 

I would like to have an expression on a Menu Dropdown controller, such that if

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

has 1 lines of text, then the dropdown menu will be value 1, if it has 2 lines the menu will be value 2, and if the text has 3 lines it will be value 3. (The default vaule of the dropdown menu should be value 2.)

 

Is there a way to do this, where you reference how many lines a text layer has with an expression?

 

Thanks!

TOPICS
Expressions , How to , Scripting
1.2K
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

correct answers 1 Correct answer

Community Expert , Sep 22, 2024 Sep 22, 2024

Something like this maybe:

thisComp.layer("Verse").text.sourceText.split("\r").length
Translate
Community Expert ,
Sep 22, 2024 Sep 22, 2024

Something like this maybe:

thisComp.layer("Verse").text.sourceText.split("\r").length
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 ,
Sep 22, 2024 Sep 22, 2024
LATEST

Works perfectly! Thanks so much.

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