The hard way would be to count the line breaks in a loop, the simple way would be to apply a text selector with mode set to lines and link the Start/End values to wherever you need them...
if you use it as and expression on the sourceText of the layer with the text : value.split(/\n|\r/).length
on a different layer targeting a text layer called myTextLayer : thisComp.layer("myTextLayer").text.sourceText.split(/\n|\r/).length
Thanks, it is really close what I need, but it detect only if I press Enter and do next line. But I need check number of lines, but lines which made After Effect automaticly when I write without Enter. My question was not exact, so sorry.
All story: I read many text from external file to After Effect, then I load this different long text to text object in AE. But AE can not center text verticaly (if yes, it will solve my problem) so I need check number of lines, which was generated by After Effect. No Enter was pressed. When I will have number of lines, I can change position Y and text will be aligned inside my graphic. Text in readed file is in one line. But different count of characters. Maybe it is not possible check automatic lining ...
Method with Range Selection is not working in this case. It is true, that it write number of lines, but when I read another text from file, it hold same value.
Sorry for my english
There is no way to do this with expressions. Only scripts can read area text shape size and other font properties, but even then you need to input some values into your formula manually, because naturally the visible content of a font is different from the em box of the letters and other specifics like glyph substitution, custom baseline settings and whatnot may matter.
I try just add \n to my input text and it is working great with thisComp.layer("myTextLayer").text.sourceText.split(/\n|\r/).length
so when I synchronize my graphic, with input formular (width) it will works, thank you guys!