Skip to main content
Inspiring
September 22, 2024
Answered

Expression to count number of lines in a text layer

  • September 22, 2024
  • 1 reply
  • 1449 views

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!

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

Something like this maybe:

thisComp.layer("Verse").text.sourceText.split("\r").length

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
September 22, 2024

Something like this maybe:

thisComp.layer("Verse").text.sourceText.split("\r").length
kg77Author
Inspiring
September 22, 2024

Works perfectly! Thanks so much.