Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression question: Lock position of layer to text length

  • Expression question: Lock position of layer to text length

    Posted by Taso Mastorakis on January 18, 2018 at 11:09 pm

    Hey everyone, I’m sort of a novice with expressions and I found this one from Dan that almost does what I need it to:

    gap = 10;
    L = thisComp.layer(“text”);
    rect = L.sourceRectAtTime(time,false);
    x = L.toComp([rect.left+rect.width,0])[0];
    [x+gap+width/2,value[1]]

    It works great if the text layer is left justified moving to the right. Just wondering how I can reverse this to be right justified and have the secondary layer move to the left. I’ve tried switching a number of the attributes but nothing seems to work. Thanks in advance.

    Gates Bradley replied 8 years, 3 months ago 3 Members · 3 Replies
  • 3 Replies
  • Cassius Marques

    January 19, 2018 at 7:41 pm

    since he seems to be measuring the left boundary of the rectangle (created by the drawing of the text) and adding to it its width. (x = L.toComp([rect.left+rect.width,0])[0];) thus getting a position in relation to the comp thats allways to the right of the text box.

    You may have to just remove the rect.width. You’ll end up with the position of the left boundary, and thats it.

    Try

    gap = 10;
    L = thisComp.layer("text");
    rect = L.sourceRectAtTime(time,false);
    x = L.toComp([rect.left,0])[0];
    [x-gap-width/2,value[1]]

    I’m rendering now and can’t test it.

    Cassius Marques
    http://www.zapfilmes.com

  • Taso Mastorakis

    January 19, 2018 at 8:26 pm

    That worked perfectly. Thank you so much. I’ve been racking my brain all day.

  • Gates Bradley

    January 19, 2018 at 11:07 pm

    Haha, hey Taso what’s up. Looks like we’re both on here working out problems. Wish I could help you with your expression. I could use the same.

    Ok carry on.

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