G
G
Gulyavkov2019-04-03 06:33:15
Adobe After Effects
Gulyavkov, 2019-04-03 06:33:15

How to automate animation?

How to automate the capture of text by a shape? Now I did it manually, through position for each layer
5ca428bbb3b85401786953.gif

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DarkWood, 2019-07-05
@DarkWood

I know that it's been two months, but I stumbled upon it by accident and decided to answer.
Actually, create layers with shape and text. For a shape, use keyframes to set the start and end position ( Position method ; "hot key" P ). Enter the following expression in the Position
method of the text layer:

x = transform.position[0];
y = transform.position[1];
shape_y = thisComp.layer("Shape Layer 1").transform.position[1];
if ( shape_y > y ) {
    [x,y];
} else {
    [x,shape_y];
}

The logic of work.
The expression reads the current values ​​of the positions along the Y axis for both layers. Since the shape layer is below the text, its initial value will be larger. And while it remains so, the position of the text will not change. When they are equal, the position of the text along the Y axis will be obtained from the shape.
Addition. If you want to automatically fit the size of the shape to the size of the label, then enter the following expression in the Rectangle> Rectangle Path> Size property :
margin = 14;
text_width = thisComp.layer("Sample").sourceRectAtTime().width;
text_height = thisComp.layer("Sample").sourceRectAtTime().height;
box_width = text_width + margin*4;
box_height = text_height + margin*2;
[box_width, box_height]

Indentation settings to taste. The name of the text layer in your case will be different - do not forget to change it or add it by index so that you do not change the name each time.
The last code in a modified form is taken from the Internet.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question