Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

expression for length of text layer

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Ryan Fyffeexpression for length of text layer
by on Nov 6, 2008 at 8:44:57 pm

Hello everyone,

Is there a way to measure the total width (and height) of a text layer, to automatically update the length (and height) of a shape layer? I produce web news segments with 7-15 lower thirds displays for each video. I'm looking for a more efficient way to re-size each nameplate. Currently I manually re-size each shape layer to fit the name. Is there an expression that will update the shape layer, based on the length (in pixels) of the text layer?

See an example video of what I'm talking about:
http://dallasvoice.com/dvtv_track.php?s=345
(look for the nameplates that animate-in at the beginning of each interview)

I've read everything I can get my hands on, but nothing has helped. Any help would be appreciated!
-RY


Return to posts index
Reply   Like  

Dan EbbertsRe: expression for length of text layer
by on Nov 7, 2008 at 12:01:00 am

You can't do it in a straight-forward way with expressions. There is, however, a hack where you can use sampleImage() to find the extents of a text layer.

The extents are available to scripting, so you could run a script that would go through your project and clean things up for you after you establish all the text. That's probably the way I'd go. Not trivial, but not too tough.


Dan



Return to posts index
Reply   Like  

cowcowcow
Trent ArmstrongRe: expression for length of text layer
by on Nov 11, 2008 at 4:10:27 am

temp = thisComp.layer("TEXT").text.sourceText;
s = temp.length;

x = 100 * (s * .175);
[x, value[1]]


I have goofy HACK that might need some tweaking.

Either call your text layer "TEXT" or change the name in the expression. And apply the expression to the Scale of your solid.

I tested it a few times and it seemed to work okay. You'll probably have to adjust the number you multiply "s" by to go with your particular font and tracking.

(Dan, can you make this more elegant?)

Trent





Trent Armstrong - Creative Cow Leader
http://www.dallasaeug.com


Return to posts index
Reply   Like  
+1


Dan EbbertsRe: expression for length of text layer
by on Nov 11, 2008 at 5:39:35 am

This would work for a mono-spaced font, but I think it would break down with a long string in a proportional font. There's a brute force way of doing this - you create a table of the width of each character (a dedicated font editing program helps). Then your expression just adds up the width of each character in the string. It's a bit of work to set up, but it's fairly accurate.

Dan



Return to posts index
Reply   Like  

Ryan FyffeRe: expression for length of text layer
by on Nov 12, 2008 at 4:26:12 am

Wow, Trent. You've completely saved my day! This issue arose because my coworkers remain blissfully ignorant of After Effects and it's wonders. Since they wouldn't learn something new, they're now getting an easy-to-use template for making their own nameplates!

I plugged the script in to the scale property, as you said....and KABOOM! it worked! Just a little bit of tweaking was needed, but it was easy enough to get the X value right :-D

in short, THANKS THANKS!
RY



Return to posts index
Reply   Like  

Kiera PolyakovaRe: expression for length of text layer
by on Feb 23, 2009 at 11:22:05 am

I've used that simple method of changing a box lenth. And I've just added a Slider Control (in text layer, named "BOX X CORRECTION") that corrects the length to exact value (Notice that instead of shape layer I've used simple layer with mask and I just change its X position and I use a link to text layer with an offset of two layers above (-2))

temp=thisComp.layer(thisLayer,-2).text.sourceText;
xps = temp.length;
xps = 100 * (xps * .125)-250+ thisComp.layer(thisLayer,-2).effect("BOX X CORRECTION")("Slider");;
if (xps<-140) (xps=-140);
yps=thisProperty[1];
[xps,yps]



Return to posts index
Reply   Like  
+1


Juan IbanezRe: expression for length of text layer
by on Jun 5, 2013 at 1:55:03 pm

Kiera where can I take a look at your example? Thanks.


Return to posts index
Reply   Like  

jay bhanushaliRe: expression for length of text layer
by on Sep 21, 2013 at 8:23:46 am

Hi Keria,

Can we get to see the after effects file you have created?
I would be of great help if you provide us with the after effects project file.

Thanks
Jay


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]