Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Using sourceRectAtTime(); to link two boxes together

  • Using sourceRectAtTime(); to link two boxes together

  • Donald Chinkeret

    November 13, 2019 at 12:02 am

    I have 4 layers that make up a lower third.
    Name, Title, Name Box, Title Box

    In Name Box, under contents>rectangle 1>rectangle Path 1>Size I have this expression:
    [title.width+L, title.height+H]

    (the sliders are there to give padding around the text)

    Under contents>rectangle 1>rectangle Path 1>Position I have this expression:
    content(“Rectangle 1”).content(“Rectangle Path 1”).size/2

    (This is to keep things left aligned)

    The Title Box has the same expressions, but referencing the layer “title” instead of “name.”

    What I’m trying to do is link the position of Title Box to the Name Box so that as the Name Box gets taller or shorter, the Title Box will remain the same distance from the Name Box.

    What expression can I use to do this?I know I need to use sourceRectAtTime to find the height of the first box and somehow tell the

  • Andrei Popa

    November 13, 2019 at 7:45 am

    I would try to align the anchor of the shape layers to left. Try using this script i made for anchor point placement.

    Then add to the position the part of the sourceRectAtTime that you want. If you want one rectangle to be to the left of the other, then position should have something like this:

    prevPosition = thisComp.layer("Rectangle 1"). position;
    prevWidth = thisComp.layer("Rectangle 1").sourceRectAtTime(time,false).width;
    [prePosition[0]+prevWidth, value[1]]

    Similar to this, if you want them to be one under the other, you use the anchorPoint script. This is even easier. Set the anchorPoint to the top left for the bottom layer and bot left to the top layer. And let’s say you want the bottom layer to be aligned vertically and with a 20 px space under the top. Top being Rectangle 1, this is the position expression:

    prevPosition = thisComp.layer("Rectangle 1").position;
    padding = 20;
    [prevPosition[0]+padding, prevPosition[1]]

    My Envato portfolio.

Viewing 1 - 2 of 2 posts

Log in to reply.

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