Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions After Effects – Variable Text Alignment

  • Filip Vandueren

    May 29, 2022 at 10:15 am

    Hi Lance,

    You can find an example project of mine here:

    https://imgur.com/gallery/uh1GbDu

    https://we.tl/t-3X3wBdYWIJ

  • Lance Clayton

    May 29, 2022 at 10:21 am

    Filip,

    Thank you! – this is a great resource and learning tool.

    Thanks for sharing.

    Lance

  • Lance Clayton

    May 29, 2022 at 10:51 am

    Filip,

    I applied your approach to a ‘text box’ (ie with a bounding box) vs a text layer without defined linebreak limits.

    How do you actually define the leftmost and rightmost alignments? (see that mine does’t reach the edges in a 4k comp (2x your resolution)?

    I see that your’s defines the right/leftmost by the longest word…

    Thanks,

  • Filip Vandueren

    May 29, 2022 at 11:46 am

    Correct I used the longets line,

    currently there is no (convenient) way to retrieve the actual dimensions of a text-box using expressions.

    but you could hard-code it like

    maxWidth = 3900;

    One approach of finding out the (approximate) actual width of a textbox I can think of, is to set the value of the sourceText (at a certain time) to:

    if (time==-0.01) {
    txt="|".repeat(10000);
    style.setTracking(-250).setFontSize(10).setText(txt);
    } else { value }

    then

    thisComp.layer("txt").sourceRectAtTime(-0.01).width;

    would be a pretty accurate width.

    but that’s just purely academical and not very practical (as 90% of my solutions 😉 )

  • Lance Clayton

    May 29, 2022 at 11:53 am

    I’ve got it working nicely enough now.

    I did swap one line defining the width to 96.5% of the comp width (to accomodate for my margins to the side)

    That said, it breaks when/if you use the Scale Composition script to resize the comp. As long as no-one does that we should be A-okay.

    Thanks again for your brilliant guidance to a great solution.

    —–

    // selectorValue * textIndex/textTotal

    widths=thisComp.layer(“lineWidths”).text.sourceText.split(“,”).map(a=>parseFloat(a));

    maxWidth =thisComp.width*0.965;

    delay = effect(“delay”)(“Slider”).value;

    align = effect(“left – ctr – right”)(“Slider”).valueAtTime(time-textIndex*delay);

    (maxWidth-widths[textIndex-1])*align/10000;

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