Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How can I get number of lines of a text layer if the source text is variable?

  • How can I get number of lines of a text layer if the source text is variable?

    Posted by Rasit Ayaz on April 15, 2023 at 2:01 pm

    I’m new to AE scripts, so excuse my lack of knowledge.

    The expression I’m using to calculate number of lines is;

    L = thisLayer;
    var newStyle = L.text.sourceText.style;
    var myLeading = newStyle.autoLeading ? newStyle.fontSize * 1.2 : newStyle.leading;

    H = L.sourceRectAtTime(time, false).height;

    rowNo = Math.ceil(H / myLeading);

    
    

    which I found from Andrei Popa’s answer for this discussion.

    The expression works fine when the source text doesn’t change, but when I insert keyframes to source text to change it, the script just calculates the number of lines based on the first keyframe and stays the same for all frames. Is this the normal behavior? What else can I try to achieve this?

    Rasit Ayaz replied 5 months, 1 week ago 3 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    April 16, 2023 at 2:51 pm

    Hi Rasit,

    it works correctly for me with multiple text keyframes,

    even when those keyframes have different style settings.

  • Trevor Asquerthian

    April 16, 2023 at 3:33 pm

    I have issues if it’s in the same text layer. Try using the expression in a different layer? Works for me then.

  • Rasit Ayaz

    April 17, 2023 at 10:31 am

    It appears my text layer was somehow broken, not sure why, but created a new text layer and it worked like a charm.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy