ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

2 line sourceRectAtTime expression problem

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Steve Thurow
2 line sourceRectAtTime expression problem
on Jul 11, 2017 at 9:04:06 pm
Last Edited By Steve Thurow on Jul 11, 2017 at 9:05:02 pm

I have a two line lower third and I want the width of the BG box to track the longer of two lines. I have one line working great however when I add what I think will work I get a reserved word error when it gets to x=.



Thanks for the help,

Steve

s1=thisComp.layer(index-1);
s2=thisComp.layer(index-2);
w1=s1.sourceRectAtTime(time-s1.inPoint,true).width
w2=s2.sourceRectAtTime(time-s2.inPoint,true).width
padding=40;
x= if(s1>s2)w1 else w2;
y1=s1.sourceRectAtTime(time-s1.inPoint,true).height;
y2=s2.sourceRectAtTime(time-s2.inPoint,true).height;
y=y1+y2;
[x+padding,y+padding]


Return to posts index

Dan Ebberts
Re: 2 line sourceRectAtTime expression problem
on Jul 11, 2017 at 10:37:41 pm

Try this for line 6:

x = (s1>s2) ? w1 : w2;

Dan



Return to posts index

Steve Thurow
Re: 2 line sourceRectAtTime expression problem
on Jul 11, 2017 at 11:54:43 pm

Thanks Dan. I'll report back with results.


Return to posts index


Steve Thurow
Re: 2 line sourceRectAtTime expression problem
on Jul 12, 2017 at 12:56:39 pm

This line of code lets the BG box resize to S2 and ignores S1 entirely but the error is gone. I am going to see if I can use a variable with an if/else statement for X. Again thanks for your input.


Return to posts index

Dan Ebberts
Re: 2 line sourceRectAtTime expression problem
on Jul 12, 2017 at 1:09:03 pm

Try it this way:

s1=thisComp.layer(index-1);
s2=thisComp.layer(index-2);
w1=s1.sourceRectAtTime(time-s1.inPoint,true).width;
w2=s2.sourceRectAtTime(time-s2.inPoint,true).width;
padding=40;
x = Math.max(w1,w2);
y1=s1.sourceRectAtTime(time-s1.inPoint,true).height;
y2=s2.sourceRectAtTime(time-s2.inPoint,true).height;
y=y1+y2;
[x+padding,y+padding]


Dan



Return to posts index

Steve Thurow
Re: 2 line sourceRectAtTime expression problem
on Jul 13, 2017 at 2:26:03 pm

Dan your code works amazing, in Ae 2017. I just tried it on my home computer to verify the problems I encountered and it worked flawlessly. My work computer is stuck on 2014 because of the IT department and it was not liking it at all.

Many thanks,
Steve


Return to posts index


Steve Thurow
Re: 2 line sourceRectAtTime expression problem
on Jul 12, 2017 at 2:35:36 pm

Thanks for getting back with me again. The good news is that the latest expression is not throwing an error. The bad news is the latest code is not allowing changes to the text on S1 or S2. The text tool highlights the text and goes right back to the text box, really weird, never seen anything like that. Time to abandon this for now, will reengage when I have time to bang my head against the wall.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]