Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions How can I modify this expression to make it work with multiple text layers

  • How can I modify this expression to make it work with multiple text layers

  • Finn Hitchcock

    November 16, 2019 at 9:26 pm

    Hi,

    I’ve got this expression which I use to auto size a rectangle to the size and letters of the text. I have been trying to modify/create an expression which does this, with 2 text layers.

    (I’m putting the expression in rectangle size)

    Expression:
    L=thisComp.layer(“text”);
    X=L.sourceRectAtTime().width;
    Y=L.sourceRectAtTime().height;
    [X,Y]

    Thanks in advance for help!

    F 🙂

    L=thisComp.layer("text");
    X=L.sourceRectAtTime().width;
    Y=L.sourceRectAtTime().height;
    [X,Y]

  • Dan Ebberts

    November 16, 2019 at 10:31 pm

    This is a kind of general solution, but it should do what you’re looking for:

    L1 = thisComp.layer(“text 1”);
    r1 = L1.sourceRectAtTime();
    ul1 = L1.toComp([r1.left,r1.top]);
    lr1 = L1.toComp([r1.left+r1.width,r1.top+r1.height]);
    L2 = thisComp.layer(“text 2”);
    r2 = L2.sourceRectAtTime();
    ul2 = L2.toComp([r2.left,r2.top]);
    lr2 = L2.toComp([r2.left+r2.width,r2.top+r2.height]);
    ulTot = [Math.min(ul1[0],ul2[0]),Math.min(ul1[1],ul2[1])];
    lrTot = [Math.max(lr1[0],lr2[0]),Math.max(lr1[1],lr2[1])];
    lrTot – ulTot

    Dan

Viewing 1 - 2 of 2 posts

Log in to reply.

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