Activity › Forums › Adobe After Effects Expressions › expression for length of text layer
-
expression for length of text layer
David Cabestany replied 8 years, 8 months ago 12 Members · 19 Replies
-
Dan Ebberts
July 2, 2015 at 5:50 pmsourceRectAtTime() works with both expressions and scripts. It returns an object that includes the width and height of the text’s bounding box. You would use it like this:
rect = thisComp.layer(“text”).sourceRectAtTime(time,false);
w = rect.width;
h = rect.height;Note that these results don’t include any scaling applied to the layer, so you may have to account for that separately.
Dan
-
Martin Jean-sébastien
July 3, 2015 at 8:43 amCan you tell me since which version of after effects we can use this expression?
Thanks! -
Patrick Grossien
January 19, 2016 at 11:58 amthis is weird. I’m using CC2015 and sourceRectAtTime doesn’t update properly for me.
My text is set up so that it appears over time via an animated slider:
n=thisComp.layer("john.doe@me.com").effect("Tipp Counter")("Slider");
showtext=text.sourceText.substr(0,n);
now I want to attach a blinking cursor to the appearing text at the end.L = thisComp.layer("john.doe@me.com");
r = L.sourceRectAtTime(time,false);
fromComp(L.toComp([r.left+r.width,r.top+r.height]))
The value is not being updated over time and the value itself is nowhere near it should be.
I also checked what happens with the width of sourceRectAtTime and it doesn’t update either when used solo.Any insight as to what I’m doing wrong? Or is there a bug I’m missing.
Thanks!
-
Patrick Grossien
January 19, 2016 at 11:59 amthis is weird. I’m using CC2015 and sourceRectAtTime doesn’t update properly for me.
My text is set up so that it appears over time via an animated slider:
n=thisComp.layer("john.doe@me.com").effect("Tipp Counter")("Slider");
showtext=text.sourceText.substr(0,n);
now I want to attach a blinking cursor to the appearing text at the end.L = thisComp.layer("john.doe@me.com");
r = L.sourceRectAtTime(time,false);
fromComp(L.toComp([r.left+r.width,r.top+r.height]))
The value is not being updated over time and the value itself is nowhere near it should be.
I also checked what happens with the width of sourceRectAtTime and it doesn’t update either when used solo.Any insight as to what I’m doing wrong? Or is there a bug I’m missing.
Thanks!
-
Rombout Versluijs
March 24, 2016 at 4:28 amI used this code have dynamic textfield which show my comments in a marker. Is there a method how i can set a maxwidth to that textfield so it uses line breaks automatically?
-
Alex Barnet
July 13, 2017 at 2:50 amHi everyone. The sourceRectAtTime works great, but how would I calibrate the expression so that the text box can be moved around?
-
David Cabestany
September 20, 2017 at 3:57 pmPatrick, use this expression instead:
L = text.sourceText.length;
sp=thisComp.layer("xp").effect("Speed")("Slider");
st=thisComp.layer("xp").effect("Start At")("Slider");
PT = time - thisLayer.inPoint;
T = PT*sp-st*sp;
F = Math.round(PT % 1);if(F == 1 | (T0) )
{Fl = "|"} // cambia la letra/simbolo dentro de las comillas
else{Fl ="";}substr(0,T) + Fl
Reply to this Discussion! Login or Sign Up