Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Center anchorpoint, no matter the content of text field

  • Center anchorpoint, no matter the content of text field

  • Sebastian Rasche

    February 2, 2018 at 3:30 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 ];

  • Scott McGee

    February 2, 2018 at 4:28 pm

    This should work

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

  • Sebastian Rasche

    February 2, 2018 at 5:18 pm

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

  • Sebastian Rasche

    February 2, 2018 at 5:24 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 ];

  • Scott McGee

    February 2, 2018 at 7:35 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]

  • Sebastian Rasche

    February 3, 2018 at 3:50 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];

Viewing 1 - 6 of 6 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy