FORUMS: list search recent posts

Get number of wrapped lines from some paragraph text

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Paul Roper
Get number of wrapped lines from some paragraph text
on Nov 22, 2013 at 3:18:56 pm

I have used the expression (below - which I think I got from this site, from one of the expression geniuses) to get the number of lines in a chunk of text by counting the number of "newline" characters ( \r on Mac OS X). But if I have a chunk of paragraph text, with wrapped lines, this will not work. I've tried using \n instead, which I've read is the "newer" carriage return character for Mac OS X but this always just returns "1" regardless of the text.

I'm trying to align a shape layer's y-position with each new line - similar to bullet points:
  • This is the first bullet of text.
  • This is the second. The bullets always stay with the first line regardless of how much the chunk of text has wrapped, even if it goes over several lines.
  • And more text....

Any suggestions, anyone?



textLayer = thisComp.layer("body text");
newLineChar = "r";
newLines = 0;
for( i = 0 ;
i &lt; textLayer.text.sourceText.length; i++ )
if( textLayer.text.sourceText.charAt( i ) == newLineChar)

Return to posts index

Kevin Camp
Re: Get number of wrapped lines from some paragraph text
on Nov 22, 2013 at 7:25:34 pm

i've never found a way, maybe some one can give a definitive answer... so i'll stop trying to do this ;)

i know ae knows how many lines are in a text paragraph layer, because if you do add text animator to a paragraph text layer that has wrapping lines, twirl down the advanced tab, set 'based on' to lines and 'units' to index, low-and-behold the end point changes to the number of lines in the text layer.

**before you get to excited, thinking that you can just link you expression to the end point value of that text layer (as i did once), that end point value doesn't update with a source text update.. so if the first time you try this the end point value is '3', it will remain 3 despite how many times lines are in there the next time you type (or copy/paste).

Kevin Camp
Senior Designer

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved