Skip to main content
Inspiring
Sep 22, 2024 9:10 PM UTC
Answered

Expression to count number of lines in a text layer

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 is closed to new replies. Start a new post to keep the conversation going.
Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
Sep 22, 2024 11:35 PM UTC

Something like this maybe:

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

2 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
Sep 22, 2024 11:35 PM UTC

Something like this maybe:

thisComp.layer("Verse").text.sourceText.split("\r").length
Translate
kg77Author
Inspiring
Sep 22, 2024 11:53 PM UTC

Works perfectly! Thanks so much.

Translate