-
finding the longest text
Hi all, if i have an if else statement in a project that controls the length of a solid based on the length of the text.
It was easy for 2 text layers, because i assigned x to the length of a text layer with sourcerectattime, and y to the other text layer. and I am using a specific time also because of the animation of the text ( so lets say the 2 second mark )
Now I have more layers, and also some of these layers are coming in later, lets say 7 seconds. So I am not sure how to solve this without making this more complicated.
here is my original expression,
gap = 36;
L = thisComp.layer(“TEXT1”);
M = thisComp.layer(“TEXT2”);
rect = L.sourceRectAtTime();
rect2 = M.sourceRectAtTime();
x = L.toComp([rect.left+rect.width,0],2)[0];
y = M.toComp([rect2.left+rect2.width,0],2)[0];
xclamp=clamp(x,545.70,2000);
yclamp=clamp(y,545.70,2000);
if (x>y) xclamp+gap;
else yclamp+gap
now if I only add 1 more layer, my expression would be this
gap = 36;
L = thisComp.layer(“TEXT1”);
M = thisComp.layer(“TEXT2”);
N = thisComp.layer(“TEXT3”);
rect = L.sourceRectAtTime();
rect2 = M.sourceRectAtTime();
rect3 = N.sourceRectAtTime();
x = L.toComp([rect.left+rect.width,0],2)[0];
y = M.toComp([rect2.left+rect2.width,0],2)[0];
z = N.toComp([rect3.left+rect3.width,0],7)[0];
xclamp=clamp(x,545.70,2000);
yclamp=clamp(y,545.70,2000);
zclamp=clamp(z,545.70,2000);
if (x>y)&&(x>z) xclamp+gap;
if (y>x)&&(y>z) yclamp+gap;
else zclamp+gap
so if i had 6 text layers, this expression would be extremely long. Is there a function I am not aware of that would allow me to bypass writing 5 if else statements each having 5 ”&&” like this for example ;
( this is just 1 line )
if (x>y)&&(x>z)&&(x>z2)&&(x>z3)&&(x>z4) xclamp+gap; and so on….
thanks for any help