Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Auto-resize text box -> Box doesn’t stay in place

  • Auto-resize text box -> Box doesn’t stay in place

    Posted by Aniello Ferrone on October 9, 2019 at 10:36 am

    Hi masters, how are you? I saw a lot of guide to self-resize box, but nobody seems to care about this problem.

    I made an auto-resize text box, and i really like this expression I used in the position of the shape layer, that allows me to scale the box proportionally and justify the text (paragraph) both right and left. Here it is

    var s = thisComp.layer(“Text”) ;
    var h = s.sourceRectAtTime().height/2 ;
    var w = s.sourceRectAtTime().width/2 ;
    var t = s.sourceRectAtTime().top ;
    var l= s.sourceRectAtTime().left ;

    [w+l,h+t] ;

    The only problem with this expression, is that the position of the box slightly change everytime, according to different lenght of text (like you see in this video)
    https://www.dropbox.com/s/4qrihc4onncaj6u/expample.mov?dl=0

    When I used just this one in the position, it didn’t happen

    content(“Rectangle 1”).content(“Rectangle Path 1”).size/2

    So I want the box to stay in place, how can i do?

    Thanks to the help your giving me those days
    Aniello

    Aniello Ferrone
    Viral Video Editor
    http://www.fanpage.it

    Tomas Bumbulevičius replied 6 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Aniello Ferrone

    October 9, 2019 at 11:21 am

    I think this is the problem, but i can’t understand how to set it

    var l= s.sourceRectAtTime().left ;

    Aniello Ferrone
    Viral Video Editor
    http://www.fanpage.it

  • Tomas Bumbulevičius

    October 13, 2019 at 2:10 pm

    Hey Aniello, try applying the following expression to shape’s anchor point. It will stick in the middle for this case.

    In order to changes its anchor point placement, adjust value in the brackets, to reflect it.

    Currently, it reads ‘take left value of the layer, add half of layer’s width’ for X, and then ‘take top value of the layer and add half of its height’. This results to a center value in both, x and y. Based on this relation, you will manage to make it work to your case.

    sourceSize = thisLayer.sourceRectAtTime(0, 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

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