Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link position to corner of object

  • Link position to corner of object

    Posted by Baard Kolstad on September 20, 2016 at 11:53 am

    I’m trying to dynamically link a text layer’s position to the upper left corner of a rectangle. I am aware that this can be achieved by repositioning the anchor point of the rectangle to the upper left corner, and then linking the text layer’s position to the anchor point of the rectangle, but in this case I need the anchor point of the rectangle to be in the lower left corner. The result I am trying to achieve is that I can scale the rectangle while the text layer follows along (only in position, not scaling along). It would also be great if it was a principle that could be applied to any corner.

    Here is a image showing what I’m trying to achieve, the green circle being the anchor point:

    Thanks in advance for all help!

    Baard Kolstad replied 9 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 20, 2016 at 4:07 pm

    If a rectangle is a solid, this should work:

    L = thisComp.layer(“Rectangle”);
    offset = [50,50];
    L.toComp([0,0]) + offset

    Adjust offset to get the text exactly where you want it in relation to the corner.

    If it’s a shape layer, it gets slightly more complicated.

    Dan

  • Baard Kolstad

    September 20, 2016 at 5:39 pm

    Thanks for the reply Dan! In this case it is shape layers, unless there’s some way of converting illustrator rectangles to solids, except manually. I would really appreciate if you could go through the process with shape layers.

    Thanks so much again.

  • Dan Ebberts

    September 20, 2016 at 5:54 pm

    Try this:

    L = thisComp.layer(“Rectangle”);
    offset = [50,50];
    r = L.sourceRectAtTime(time,false)
    L.toComp([r.left,r.top]) + offset

    Dan

  • Baard Kolstad

    September 20, 2016 at 8:56 pm

    Works like a charm. Really appreciate the help!

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