Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions interpolating from source text keyframe to the next

  • interpolating from source text keyframe to the next

    Posted by Roei Tzoref on October 19, 2017 at 7:48 pm

    Hi
    I am trying to make source.rectAtTime to work in interpolating text changes in the same layer.
    I got it to work with 2 separate layers but I need it to work for one.
    Hi. so I got this to work for 2 text layers: https://imgur.com/a/i976B
    I am trying to make this work for one text layer using source text keyframes. is that possible?

    here’s a preview of the animation I am trying to make. first the rectangle stretches, then the animators kick in.

    this is what I enter in scale for the shape
    T= thisComp.layer(“text_1”);
    T2=thisComp.layer(“text_2”);

    trans = effect(“transition”)(“Slider”);

    x1 = T.sourceRectAtTime(time-inPoint).width+18;
    x2 = T2.sourceRectAtTime(time-inPoint).width+18;

    x = linear(trans,0,100,x1,x2);
    [x,26]

    this is what I enter for the animation which is triggered by a marker in another layer
    preroll = 0;
    L= thisComp.layer(“Controller”);
    n = 0;
    t0 = time + preroll;
    if (L.marker.numKeys > 0){
    n = L.marker.nearestKey(t0).index;
    if (L.marker.key(n).time > t0) n–;
    }
    if (n < 2){
    t = 0;
    }else{
    t = t0 – L.marker.key(n).time;
    }
    valueAtTime(t)

    but I am trying to make this happen with only one layer because this is a template and if someone needs more text he can add them, if not then no need. so I can’t have multiple text layers in there.

    Roei Tzoref
    2D/VFX Generalist & Instructor
    ♫ AeBlues Tutorials ♫
    http://www.tzoref.com

    View post on imgur.com

    Roei Tzoref replied 5 years, 11 months ago 2 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    October 19, 2017 at 11:12 pm

    If you have the text keyframed in one layer, you should be able to pick up the appropriate text widths by using the keyframe times to calculate the time paramters to use with sourceRectAtTime(), so you get the correct widths. Is that what you’re asking?

    Dan

  • Roei Tzoref

    October 20, 2017 at 12:23 am

    Yes. Thank you.

    Roei Tzoref
    2D/VFX Generalist & Instructor
    ♫ AeBlues Tutorials ♫
    http://www.tzoref.com

  • Roei Tzoref

    October 20, 2017 at 6:13 pm

    I am looking for a way for the rectangle to transition from one source keyframe to the next (on the same text layer). since the source keyframe are hold keyframes I only get a cut. I need a transition. how can I call the keyframes on the source text so that the widths will transition from one key frame to the next?

    Roei Tzoref
    2D/VFX Generalist & Instructor
    ♫ AeBlues Tutorials ♫
    http://www.tzoref.com

  • Dan Ebberts

    October 20, 2017 at 6:52 pm

    I’m confused. Wouldn’t you still use linear() to transition between the two widths? I think all you need from the text keyframes are the times so you can get the correct text widths to use with linear(). I may be missing something because I don’t fully understand what you’re doing with the transition.

    Dan

  • Roei Tzoref

    October 20, 2017 at 7:45 pm

    [Dan Ebberts] “I think all you need from the text keyframes are the times so you can get the correct text widths to use with linear()”

    how do I get those? how do I get the string of code that say’s “whenever text source width is changed, transition from one to the next?”
    please bare in mind that although I am by mistake in the expression forum avatar row, I know too little about them and managed my way barely through the difficult aspects of this project. this the last thing I need for it (hopefully) and I have already resorted to fix this issue in another way which does not involve an elegant expression and just one layer, but this is my last attempt. feel free to proceed in your affairs if this gets too confusing.

    so in short – how do I create a rectangle to attach to a text layer source text keyframe, so whenever I change the text by keyframing the source text, the rectangle transitions from one width to the next?

    this is my testing here:
    I got the idea to work based on 2 text layers width, but I want it to be based on source text keyframes of the same text layer.

    I got this to work on 2 text layers:
    T= thisComp.layer(“text_1”);
    T2=thisComp.layer(“text_2”);

    trans = effect(“transition”)(“Slider”);

    x1 = T.sourceRectAtTime(time-inPoint).width+18;
    x2 = T2.sourceRectAtTime(time-inPoint).width+18;

    x = linear(trans,0,100,x1,x2);
    [x,26]

    but what I really need is this to work on one text layer maybe like this: (doesn’t work I am just trying to make it work)

    T= thisComp.layer(“text”).text.sourceText.key(1).time; // just a guess here – I need the previous key here
    T2=thisComp.layer(“text”).text.sourceText.key(2).time; // this is probably wrong – I need the following key here

    trans = effect(“transition”)(“Slider”); // just an expression slider with keyframes from 0 to 100

    x1 = T.sourceRectAtTime(time-inPoint).width+18;
    x2 = T2.sourceRectAtTime(time-inPoint).width+18;

    x = linear(trans,0,100,x1,x2);
    [x,26]

    here’s a project file with just that setup if you have the time to take a look:

    https://drive.google.com/open?id=0B5wyUt17-tu2QUd2M1BzRHhNSGc

    the setup is more complex but the other stuff I can figure out, I just need the part that changes width linearly and not on a cut…

    appreciate it thanks.

    Roei Tzoref
    2D/VFX Generalist & Instructor
    ♫ AeBlues Tutorials ♫
    http://www.tzoref.com

  • Dan Ebberts

    October 20, 2017 at 9:06 pm

    I’d do something like this:


    T = thisComp.layer("Text");
    transDur = .25;
    txt = T.text.sourceText;
    x = value[0];
    if (txt.numKeys > 0){
    n = txt.nearestKey(time).index;
    if (time < txt.key(n).time) n--;
    if (n > 0){
    if (n > 1){
    t1 = txt.key(n-1).time;
    t2 = txt.key(n).time;
    x1 = T.sourceRectAtTime(t1,false).width+18;
    x2 = T.sourceRectAtTime(t2,false).width+18;
    x = linear(time,t2,t2+transDur,x1,x2);
    }else{
    x = T.sourceRectAtTime(time,false).width+18;
    }
    }
    }
    [x,26]

    Dan

  • Roei Tzoref

    October 21, 2017 at 12:49 am

    Thanks Dan. this appears to work but I am just too confused by all the code so I will put this to rest and resort to a keyframe based approach in this case. will learn the methods you showed me in the last few days so I can figure these out for myself in the long run.

    have a good weekend my friend.

    Roei Tzoref
    2D/VFX Generalist & Instructor
    ♫ AeBlues Tutorials ♫
    http://www.tzoref.com

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