Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Dynamically adjust position of shape layer to text

  • Dynamically adjust position of shape layer to text

    Posted by Ricky London on October 15, 2019 at 6:26 pm

    Hi All,

    I would like to have the red shapelayer start at the beginning of the text and end at the last character of the text with alittle breathing room.

    i’m not sure where to start with the expression! (I think something like linking the shapelayer x position to the first and last character count + any extra space needed) hope someone can help.

    13821_lefttoright.gif.zip

    Thanks,
    K

    Kyle Maven replied 6 years, 9 months ago 3 Members · 2 Replies
  • 2 Replies
  • Tomas Bumbulevičius

    October 16, 2019 at 9:21 am

    Hey Ricky, more information is needed about your layout and use case scenario.

    1. Are you going to place this strictly in some area of the screen, or not?
    2. What flexibility is preferred to adjust there?

    Anyways, to breakdown this quickly if this is center aligned:
    1. Instead of path, use thin rectangle.
    2. Use sourceRectAtTime to get ‘text layer’ size.
    3. Apply paddings by attaching sliders to rect shape’s x and y.
    4. Animate horizontally by using interpolation: ease(time, inTime, outTme, rectLeftEdge, rectsRightEdge)
    5. Apply expression to text and rect shape:

    sourceSize = thisLayer.sourceRectAtTime(time, false);
    T = sourceSize.top;
    L = sourceSize.left;
    W = sourceSize.width;
    H = sourceSize.height;
    ([L+ W/2,T+H/2])

    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.
    Boxer – Dynamic Text Boxes Template with a Live Preview

  • Kyle Maven

    October 18, 2019 at 3:06 pm

    1. Create a new shape layer
    2. Create a 2-point line with the pen tool
    3. click on the shape path in the timeline panel
    4. Window>Create Nulls From Paths>Points Follow Nulls
    5. Use Tomas Bumbulevičius expression for both null’s positions with the Text Layer as your Source.
    -Null 1 should have an expression that positions it always on the left side
    -Null 2 should have an expression that positions it always on the RIGHT side
    6. Click on the shape path in the timeline panel
    7. Window>Create Nulls From Paths>Trace Path
    8. Shift + Parent your red shape layer to this new null

    this will animate the shape on the x-axis based on the width of the Text. I haven’t done this in a long time but I know it took some experimenting with the expressions. There are ways to add “padding” within the expressions that links to sliders.

    I would suggest watching some tutorials and looking more into the sourceRectAtTime() expression.

    https://www.youtube.com/watch?v=In4miXUdxko

    I hope this helps!

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

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