Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Find the Position of a Specific Character in a Text Layer

  • Find the Position of a Specific Character in a Text Layer

    Posted by Erin Prysiazny on August 20, 2019 at 2:31 am

    Hey!

    I’ve been creating a template for a client and I want to have a precomped animation be positioned at the end of whatever title they type into the text layer.
    Is there a way to use expressions to find out what the position of the last character in a string is?

    Thanks in advance!
    Erin

    Dan Ebberts
    replied 7 years, 1 month ago
    2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    August 20, 2019 at 3:03 am

    This might work–it should give you the right edge of the text:

    L = thisComp.layer(“TEXT”);
    r = L.sourceRectAtTime(time,false);
    L.toComp([r.left+r.width,r.top+r.height/2])

    If you want the animation to always keep its own y value, it would be like this:

    L = thisComp.layer(“TEXT”);
    r = L.sourceRectAtTime(time,false);
    x = L.toComp([r.left+r.width,r.top+r.height/2])[0];
    [x,value[1]]

    There are other variations, depending on what you need exactly.

    Dan

  • Erin Prysiazny

    August 20, 2019 at 12:52 pm

    Thanks Dan! Will this also account for if the last line of the title is shorter than the others?

  • Dan Ebberts

    August 20, 2019 at 2:31 pm

    No, it wouldn’t work for multi-line text.

    Dan

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