Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Paragraph Text Box Control (Reversed)!

  • Paragraph Text Box Control (Reversed)!

    Posted by Bilal Alsurri on February 20, 2016 at 7:23 pm

    Hello,
    is there anyway to make a paragraph text box to be controlled by a shape layer size?

    i want to change the shape layer size (rectangle) and this cause the paragraph text box to change accordingly. i searched all the net, and everything there is taking about a shape layer that changes according to the text size using the SourceRectAtTime(), i want the reverse action?

    thanks,
    Bilal

    Bilal Alsurri replied 10 years, 7 months ago 2 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    February 21, 2016 at 8:05 am

    I assume you want the text to wrap onto new lines within the shape rectangle?

    I don’t think you can access the text bounding box, other than reading its value, with expressions.

    The only way I can think of doing this (with expressions) is some complicated combination of moving the text box position and adding (and removing) manual line breaks to try and approximate the width of the shape.

  • Kalleheikki Kannisto

    February 21, 2016 at 11:00 am

    Here’s an attempt at it. It is breaking a paragraph onto lines after a certain number of letters that depends on the width of the rectangle. It’s not that accurate, as the number of letters doesn’t necessarily correspond to length of line, but it is something. Using this, all text should be the same size and there should be no line breaks in the original source text.

    Comp has a rectangle named “Rect” and a text layer that covers the maximum size of the rectangle.

    Code for source text:

    txt = value;
    done = 0;
    esc = 0;
    len =0;
    row = Math.floor(thisComp.layer("Rect").sourceRectAtTime(time).width*thisComp.layer("Rect").scale[0]/1220);//divisor depends on type size
    while (done == 0){
    esc ++;
    len+=row;
    if (txt.length >= len+1){
    for (i = len; i > len-row; i--) if (txt[i] == " ") break;
    if (i > len-row){
    txt=txt.substr(0,i) + "\r" + txt.substr(i+1,9999);
    }
    }
    len = i;
    if (esc>100){done=1}
    }
    txt

  • Bilal Alsurri

    February 21, 2016 at 9:03 pm

    Thanks a lot Kalle, appreciate it.

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