ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Find the Position of a Specific Character in a Text Layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Erin Prysiazny
Find the Position of a Specific Character in a Text Layer
on Aug 20, 2019 at 2:31:36 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


Return to posts index

Dan Ebberts
Re: Find the Position of a Specific Character in a Text Layer
on Aug 20, 2019 at 3:03:56 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



Return to posts index

Erin Prysiazny
Re: Find the Position of a Specific Character in a Text Layer
on Aug 20, 2019 at 12:52:09 pm

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


Return to posts index


Dan Ebberts
Re: Find the Position of a Specific Character in a Text Layer
on Aug 20, 2019 at 2:31:33 pm

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

Dan



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]