Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Shape width match

  • Shape width match

    Posted by Mario Chocooj on April 15, 2023 at 11:46 pm

    Hello Folks,

    I’m creating a responsive Lower Third MOGRT where the background shape layers behind the Speaker Name and the Speaker Title text resize depending on the width of each text layer (See attached AE file).

    However, what I need to accomplish now is how to make one shape layer match the width of the widest of the background shape layers. For example: IF the Speaker Name background shape (which is defined by the width of the Speaker Name text) is longer than the Speaker Title THEN the Speaker Title background shape should resize to match the width of the Speaker Name background shape. I also would like to do the opposite so that at all times both backgrounds are the same width depending if Speaker Name or Speaker Title are the longest of the two.

    I’m not sure if I need an IF/ELSE statement or use the Math.max expression. I’m using AE 2023 on Mac.

    Any guidance on how to successfully accomplish this would be most appreciated. Or any other suggestions on how to accomplish the same effect are also appreciated.

    Filip Vandueren replied 3 years, 3 months ago 2 Members · 6 Replies
  • 6 Replies
  • Filip Vandueren

    April 16, 2023 at 3:11 pm

    Hi Mario,

    I would use Math.max like this on both “width” sliders:

    Math.max(
    thisComp.layer("Subtitle").sourceRectAtTime().width + thisComp.layer("SubtitleBg").effect("SubtitleMargin")("Slider").value
    ,
    thisComp.layer("Title").sourceRectAtTime().width + thisComp.layer("TitleBg").effect("Margin")("Slider").value
    );

    And if you use Centered paragraphs you might want to add this expression on both the sourceText properties:

    text.sourceText.trim();

    This disregards any Whitespace at start and end of a string. (they don’t count for the sourceRect width, but they do alter the layout of the paragraph, so that in an edge case, a name preceded or followed by 100 spaces pushes the text out of its box)

  • Mario Chocooj

    April 17, 2023 at 8:31 pm

    Thank you, Filip. Appreciate very much the reply. I shall try it and see what happens. I’m assuming I add the Math.max method to each of the shape layers. Correct?

  • Filip Vandueren

    April 18, 2023 at 7:57 am

    yes, the expression is formulated so that it can be used on both.

  • Mario Chocooj

    April 18, 2023 at 7:40 pm

    Really appreciate the time you took to reply. Your method works beautifully!

  • Mario Chocooj

    April 22, 2023 at 2:25 pm

    Thanks again for the guidance. Perhaps my last question is: how can I change the text to be left-aligned. Right now is centered aligned and I would prefer it if it resized from the left.

  • Filip Vandueren

    April 23, 2023 at 8:15 pm

    Hey Mario,

    in that case, one way to handle the changes is this:

    • set the Paragraph setting of both text to Left aligned
    • The control-layers have an expression on their X-positon -> disable these expressions
    • The BG-layers should get expressions for their anchorpoint:
      [effect(“SubtitleWidth”)(“Slider”)/-2, 0]
    • and for their position:
      value – [effect(“SubtitleMargin”)(“Slider”)/2,0];

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