ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Text length expressions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Daryl Judd
Text length expressions
on Mar 26, 2018 at 4:54:59 pm

I've found several threads that are close to what I need, but haven't come across the right combination. I have a comp that has a first name layer, and a last name layer. In a separate comp, I want to combine them into one row. So I need to find the length of the first name, and add that to the x-position of the second name, so they are spaced correctly. The expression works with shorter names, but doesn't adjust correctly for longer names.

Is it because length is the number of characters, which is different than the width in pixels? Any ideas of what might work?

temp = thisComp.layer("FIRST NAME").text.sourceText;
s = temp.length*25;

transform.position + s;


Daryl Judd
KVAL Graphics


Return to posts index

Roman Lehmann
Re: Text length expressions
on Mar 26, 2018 at 7:29:32 pm

Did you try the following?
- check the little sun icon (Collapse Transformation) with the two comps (you'll get the original size and not the comp size)
- use the expression sourceRectAtTime(time) explained here:




- use simple math to calculate the x-position of the Last Name-comp

cheers
roman


Return to posts index

Daryl Judd
Re: Text length expressions
on Mar 26, 2018 at 11:34:51 pm

Thank you Roman, that seems to have done the trick!

Daryl Judd
KVAL Graphics


Return to posts index

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