Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sourceRectAtTime() update when keyframing the text source ?

  • sourceRectAtTime() update when keyframing the text source ?

    Posted by Matthieu Foulet on March 31, 2017 at 1:42 pm

    Hi everyone,
    I am using the sourceRectAtTime() expression to create a box around a text layer like this :

    par=thisComp.layer("TEXT");
    rect = par.sourceRectAtTime(time,false);
    padding=thisComp.layer("Control Text").effect("Padding")("Curseur");
    w = rect.width+padding;
    h = rect.height+padding;
    [w,h]

    This works very well but I have no idea wether it’s possible to update the sourceRectAtTime() expression when I keyframe the source text of my layer.

    If anyone could point me to the right way of doing it (if it’s even possible), that would make my day !

    EDIT : I tried searching for the expression language reference on Adobe website but the sourceRectAtTime() expression is not listed…

    Matthieu Foulet replied 8 years, 10 months ago 5 Members · 8 Replies
  • 8 Replies
  • Dan Ebberts

    March 31, 2017 at 3:43 pm

    It should work. Did you try it?

    Dan

  • Kevin Camp

    March 31, 2017 at 3:43 pm

    it should update as the source text changes.

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Matthieu Foulet

    March 31, 2017 at 4:02 pm

    I deleted my layers and restarted from scratch, put back the expression and it worked as expected on any kind of layers.

    There must have been something wrong with my previous text layer, for which I copy/pasted the content from one comp to another.
    I don’t understand what but it’s now working.

    Thank you Dan and Kevin for your answers.

    Windows 10 64bits
    intel i7-5930K@3.50Ghz
    32Go DDR4 RAM
    GPU AMD Firepro W7100 8Go

  • Adam Goddard

    April 24, 2017 at 8:01 am

    Hi
    Would you please advise steps on how you used this expression with text layer. Much appreciated.

  • Matthieu Foulet

    April 24, 2017 at 12:41 pm

    Sure,
    At first, I typed my text into a comp.
    I then created a rectangle shape on a new shape layer, wich I parented to my text layer so that if will follow the text layer if I moved it within the comp.
    I then insert the following expression into the rectangle size option of the shape layer :


    par=thisLayer.parent;
    rect = par.sourceRectAtTime(time,false);
    w = rect.width;
    h = rect.height;
    [w,h]

    Finally, I adjusted the anchor point of the shape with an expression to match the anchor point of the text.

    Hope it helps, here is an AE CC file with a text and a shape, that includes some padding around the text, too.

    11291_textboxcreativecow.aep.zip

    Windows 10 64bits
    intel i7-5930K@3.50Ghz
    32Go DDR4 RAM
    GPU AMD Firepro W7100 8Go

  • Adam Goddard

    April 28, 2017 at 10:03 am

    Hi
    Thanks for your reply, apologies for my slow reply.

  • Adam Goddard

    June 26, 2017 at 11:55 pm

    Hi Matthieu
    thank you so much for sharing your comp with sourceRectAtTime(). Unfortunately, I’m stuck with working out why the 2 expression errors alert for ‘Curseur’ appear – please see screenshots. if you could let em know that would be great, thank you.

  • Matthieu Foulet

    June 27, 2017 at 6:08 am

    Sûre!
    i forgot to tell you that I am working with a French version of After Effects.
    You need to adapt the expression in English.
    To do that, you have to edit the expressions and change every time you encounter “Curseur” with “Slider”, and everything should be fine.

    Windows 10 64bits
    intel i7-5930K@3.50Ghz
    32Go DDR4 RAM
    GPU AMD Firepro W7100 8Go

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