Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions expression for length of text layer

  • Dan Ebberts

    July 2, 2015 at 5:50 pm

    sourceRectAtTime() 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 2, 2015 at 6:29 pm

    Wow thank you! Much more easier than before!

  • Martin Jean-sébastien

    July 3, 2015 at 8:43 am

    Can you tell me since which version of after effects we can use this expression?
    Thanks!

  • Dan Ebberts

    July 3, 2015 at 4:01 pm

    That was implemented in AE CC 2014.2 (I think).

    Dan

  • Patrick Grossien

    January 19, 2016 at 11:58 am

    this 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 am

    this 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 am

    I 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 am

    Hi 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 pm

    Patrick, 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

Page 2 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy