ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Center anchorpoint, no matter the content of text field

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sebastian Rasche
Center anchorpoint, no matter the content of text field
on Feb 2, 2018 at 3:30:16 pm

Hi there,

wondering if there is an expression to always center the anchorpoint on a text layer, no matter how long the lines and how many lines there are? I found this expression but it just takes the height into account. Tried to rework it for the width but it gave me a weird result. Any help appreciated.

Expression for anchorpoint:

boxTop = this.sourceRectAtTime().top; // Position of top of text box
boxHeight = this.sourceRectAtTime().height; //Height of textbox

//Offset anchor down from boxTop using half the height of the box
[value[0], boxTop + boxHeight/2 ];

boxTop = this.sourceRectAtTime().top; // Position of top of text box
boxHeight = this.sourceRectAtTime().height; //Height of textbox

//Offset anchor down from boxTop using half the height of the box
[value[0], boxTop + boxHeight/2 ];


Return to posts index

Scott McGee
Re: Center anchorpoint, no matter the content of text field
on Feb 2, 2018 at 4:28:53 pm

This should work

R = sourceRectAtTime();
[R.left + R.width/2,R.top + R.width/2]


Return to posts index

Sebastian Rasche
Re: Center anchorpoint, no matter the content of text field
on Feb 2, 2018 at 5:18:17 pm

Thanks for the reply but it is not working for me unfortunately.


Return to posts index


Scott McGee
Re: Center anchorpoint, no matter the content of text field
on Feb 2, 2018 at 7:35:39 pm

Sorry my fault, I put width again in the y part. This should work now.

R = sourceRectAtTime();
[R.left + R.width/2,R.top + R.height/2]


Return to posts index

Sebastian Rasche
Re: Center anchorpoint, no matter the content of text field
on Feb 2, 2018 at 5:24:49 pm

Somebody helped me out with this expression:

boxTop = this.sourceRectAtTime().top; // Position of top of text box
boxHeight = this.sourceRectAtTime().height; //Height of textbox

boxLeft = this.sourceRectAtTime().left // Position of left of text box
boxWidth= this.sourceRectAtTime().width; //Width of textbox

//Offset anchor
[boxLeft + boxWidth/2 , boxTop + boxHeight/2 ];


I had a another problem to accour though because I had a text effector on there which screwed with the calculation of the width.
So with the following expression it looks at the text at a certain time. I this case the 50 second marker.

boxTop = this.sourceRectAtTime(50).top; // Position of top of text box
boxHeight = this.sourceRectAtTime(50).height; //Height of textbox

boxLeft = this.sourceRectAtTime(50).left // Position of left of text box
boxWidth= this.sourceRectAtTime(50).width; //Width of textbox

//Offset anchor down from boxTop using half the height of the box
[boxLeft + boxWidth/2 , boxTop + boxHeight/2 ];


Return to posts index

Sebastian Rasche
Re: Center anchorpoint, no matter the content of text field
on Feb 3, 2018 at 3:50:17 pm

Somebody on facebook even shared a simpler expression.

R = thisLayer.sourceRectAtTime();
T = R.top;
L = R.left;
W = R.width;
H = R.height;
[L+W/2,T+H/2];


Return to posts index

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