Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to centralize two text layers to comp height

  • Expression to centralize two text layers to comp height

    Posted by Avinash Ramanath on April 6, 2021 at 5:07 am

    I have two text layers with variable sourceRectAtTime().height

    The source text for both layers is coming from a CSV sheet, hence they are different for each customer.

    I need help with an expression/method idea to centralize both to comp height

    Trent Armstrong replied 3 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Trent Armstrong

    April 6, 2021 at 1:52 pm

    If these are all set up as precomps or all the text in one layer, this solution will work.

    POSITION EXPRESSION

    L = thisComp;

    x = L.width * .5;

    y = L.height * .5;

    [x, y]

    ANCHOR POINT EXPRESSION

    L = thisLayer.sourceRectAtTime(time);

    a = L.left;

    b = L.top;

    x = L.width * .5;

    y = L.height * .5;

    [a + x, b + y]

    If you are using multiple layers to stack the lines and text together, you’ll need to do some parenting to a Null or something like that, add all the sourceRectAtTime() heights and widths together, and then do the * .5 part of the expression.

    The reason I multiply times .5 instead of dividing by 2 is just habit. When dividing by the number returned from a slider or time or size etc. it’s possible to divide by zero and that breaks an expression. So, using that for width and height makes sense to me in this situation.

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