Activity › Forums › Adobe After Effects › Expression or technique to space text from line above
-
Expression or technique to space text from line above
Posted by Matt James on March 16, 2019 at 7:28 pmHi all
I have a comp with 3 text layers, spaced nicely vertically.
I am trying to figure out a way that if line 1 was to increase in size, it would push down line 2, maintaining the space (or padding) between the layers.
I am thinking pickwhip the position of line 2 to line 1 if I could then add the height of line 1 to the position of line 2?
Image below shows what I want to achieve.
Thanks in advance.
Matt James replied 7 years, 4 months ago 3 Members · 8 Replies -
8 Replies
-
Matt James
March 17, 2019 at 1:06 amCheers Dave, but it’s for a client who doesn’t want to risk breaking anything.
Can you suggest a way to achieve this automatically?
-
Matt James
March 17, 2019 at 1:25 amI’m not sure what do with that information, but thanks?!
I’m handing the project over and they don’t want to have to do anything apart from edit text (not moving)
-
Matt James
March 17, 2019 at 11:52 amThank you Dave. But, my life choices aside, is this technically possible? (Irrelevant of real world usage)
Thanks
-
Kalleheikki Kannisto
March 17, 2019 at 4:28 pmThe short adnswer is “yes”. Similar situations have come up numerous times. Check the expressions forum for cases where someone wants to push other layers down when scaling one layer.
Kalleheikki Kannisto
Senior Graphic Designer -
Tomas Bumbulevičius
March 17, 2019 at 5:06 pmHey Matt,
it’s not that hard, and definitely – a lot more reasonable than doing it manually EVERY TIME. Manual work always leaves an area for error, and who are the ones to blame – designers, who developed solution not thoughtful enough (:
There are few things for you to consider:
1.Text will always remain 3 in lines as in example?
2. How size will be changed – by scale or by font size in characters panel?
3. What else is done with these text layers apart from the change of their text values? Are there any other transformations applied, position/anchor point/rotation?
4. Once new values are added – is it possible that it might require to change texts positions?If answered, I could help you out. Cheers.
Find out more:
After Effects Tutorials: motion design, expressions, scripting. -
Matt James
March 17, 2019 at 5:10 pmThank you Tomas.
To answer your questions:
1) In this instance, yes all three lines will be centred and remain as shown
2) I have a max-width expression on the scale property of each line. If the text exceeds 80% of the comp width, it auto scales down. Character/font size is fixed, the scale property is what will push the other lines down
3) No other transformations etc
4) No, further repositioning won’t be required.Thanks again
M
-
Tomas Bumbulevičius
March 17, 2019 at 5:33 pmAlright Matt, here is how I envision this. Assuming that scale is applied, based on the image sample, I guess anchor point is set to the top of the layer. Anyways, if not, here is the whole idea breakdown:
1. In the comp, create null layer, name it ‘control’ .
2. Apply Slider effect and name it ‘y-offset’. This will control the gap distance.
3. Assuming all text layers in the project panel are placed on after another:
ONE
TWO
THREEApply this expression to the anchor point for all layers:
sourceSize = thisLayer.sourceRectAtTime(time, false);
T = sourceSize.top;
L = sourceSize.left;
W = sourceSize.width;
H = sourceSize.height;
([L+ W/2,T+0])That way, we will get full layer height value in position expressions.
4. For second and third layer’s positions, apply this expression:
yDiff = thisComp.layer("control").effect("y-offset")(1); //Gap distance between the lines
y = thisComp.layer(index-1).transform.position[1]; //Previous layer Y position
s = thisComp.layer(index-1).transform.scale[0] / 100; //Scale ratio
h = thisComp.layer(index-1).sourceRectAtTime(time, false).height; //Previous layer height[value[0], y + s*h + yDiff]
First layer’s Y position will stay constant, others will accommodate. Change control layer’s ‘y-offset’ to set desired gap.
Find out more:
After Effects Tutorials: motion design, expressions, scripting. -
Matt James
March 17, 2019 at 6:01 pmThis is excellent and does exactly what I needed Tomas, thank you!!
Reply to this Discussion! Login or Sign Up
