Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Text Layer and Shape Layer Padding

  • Text Layer and Shape Layer Padding

    Posted by Rayan Nuri on February 25, 2025 at 6:29 pm

    Hi there! I’m a beginner in coding and expressions so i need you guys to help me in this one.

     

    I have a Project that I want to change it into a MOGRT but I’m experiencing a problem with the text and shape. I want the shape layer to change it’s position according to the length of the text while maintaining the size of the shape. I’m pretty sure that it’s done with an expression but I don’t know how.

     

    Ex: blah *, Blahblah *

    (I hope you guys got me😅)

    Dan Ebberts replied 3 weeks, 5 days ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    February 25, 2025 at 7:00 pm

    You didn’t really give enough info to provide a definitive answer, but as an example, this position expression for your shape layer will center it (assumes anchor point is in the center of the layer) in the x direction on the center of the text layer, leaving the y position as-is:

    L = thisComp.layer("Text");
    r = L.sourceRectAtTime(time,false);
    x = L.toComp([r.left + r.width/2,r.top + r.height/2])[0];
    [x,value[1]]
  • Rayan Nuri

    February 27, 2025 at 2:42 pm

    My bad for not making things clear.

    You see I want the verification icon that’s on the right to be aligned with the username, so that if I type any thing to it’s it would keep the same distance between the text and the verification icon.

    When a write a very long text the icon is getting between the text, When it’s short it’s too far from the text. Thanks again.

  • Dan Ebberts

    February 27, 2025 at 3:56 pm

    From what I can decipher from your screen shots, you should be able to use something like this:

    gap = 100;
    L = thisComp.layer(index + 1);
    r = L.sourceRectAtTime(time,false);
    x = fromComp(L.toComp([r.left + r.width, r.top]))[0];
    [x + gap, value[1]]

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