Activity › Forums › Adobe After Effects Expressions › Linking a shape layer to a text
-
Linking a shape layer to a text
Posted by Karl Lidh on September 8, 2011 at 12:35 pmHi.
Im currently asked to render hundreds of small comps where I have to manually go in and change the text for each and everyone. What makes this tedious is that the text is underlined with a shapelayer which I also have to fit to the length of text.
For now I have mapped the text to the comp name, still I cant figure how to map the length of the shape layer to match the length of the text. Can this be done?
James North replied 11 years, 5 months ago 5 Members · 8 Replies -
8 Replies
-
Dan Ebberts
September 8, 2011 at 1:22 pmI would do it with a script, using sourceRectAtTime() to get the width of the text and adjust the width of the shape layer accordingly.
There is a hack to do it with expressions, using sampleImage() to get the left and right bounds of the text, but doing that on hundreds of layers would really slow things down.
Dan
-
Karl Lidh
September 8, 2011 at 2:54 pmThank you for the reply, since I dont know that much about scripting, what would a script like that look like?
Karl
-
Dan Ebberts
September 8, 2011 at 4:02 pmHow you navigate to the layers depends a lot on the structure of your project and your naming convention for comps and layers and would make up a good part of the script. Once you get to a text layer and the corresponding shape layer, it would look something like this:
var myRect = myTextLayer.sourceRectAtTime(0,true);
var myHorizScale = (myRect.width/myShapeLayer.width)*100;
myShapeLayer.property(“Scale”).setValue([myHorizScale,100]);Dan
-
Kevin Camp
September 8, 2011 at 7:07 pmi have a method that i have used to do something similar, that may work for you too…
duplicate the text layer (maybe name it ‘underline’), and use the expression pickwhip to link that layer’s source text to the source text of the original text layer.
now apply fast blur and set it to repeat edge pixels and crank up the blur until you get a nice even color, then you can apply simple choker or some alpha correction effect to make it fully opaque if needed.
this should give you a solid ‘bar’ that is the size of the text. adjust the scale and position to create the ‘underline’.
if you really wanted, you can do this with a single layer… after the choker effect, apply the transform effect to do the scale and repositioning; cc repetile adjusting the ‘up’ property and setting tiling to ‘none’; and then cc composite, unchecking rgb only to composite the text back in. then it can be saved as a preset — whoohoo!
anyway, i hope that can help you out.
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW -
Kevin Camp
September 8, 2011 at 10:03 pmone thing that could interfere with this method is descenders… i had used this with all caps, but since this method will ‘fill’ the area that has type in it fairly tightly, the height will be effected by descenders and that may cause problems.
also the one layer method will have some issues too due to the way text layers create anchorpoints… sorry about that. i was just playing around with it and it gets pretty tweaky.
Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW -
Armand Verhoeven
January 23, 2013 at 10:12 amHi Dan,
I also try to do this method on my text animations.
But I can’t figure out where to put this expression.On the Scale of the shapelayer or the Size of the rectangle Path?
Tried both but didn’t work tho..Thank you in advance 🙂
Regards,
Armand
The Netherlands -
Dan Ebberts
January 23, 2013 at 4:20 pmThat’s a snippet of code you would put in a script, not an expression.
Dan
-
James North
December 1, 2014 at 10:10 amHiya
Im trying to learn how to do this for a university assignment & crazy stuck…I understand a lot of AE, but nothing about linking & scripting…
Is there a video tutorial or anything for this? Or an example project I can download?
Thank you,
James 😀
Reply to this Discussion! Login or Sign Up