Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
46

Expose Paragraph Text Box Width/Height for Expressions

Community Beginner ,
Sep 28, 2022 Sep 28, 2022
It's currently impossible within expressions to set the width or height of a Paragraph Text box.

This would be a massively helpful feature for text-based templates and animations.
Idea No status
TOPICS
Workflow
3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
14 Comments
Community Expert ,
Sep 28, 2022 Sep 28, 2022

While you're right that this would be a really useful addition, if Adobe do add it, no one would watch my tutorial showing a workaround 😉 

Translate
Report
New Here ,
Sep 28, 2022 Sep 28, 2022
I hope that being able to set the text area's size by expression. I think, the current text area is inconvenient.
Translate
Report
New Here ,
Sep 28, 2022 Sep 28, 2022
To control text wrapping and other applications, it is necessary to address the text box via expression.
Translate
Report
New Here ,
Sep 28, 2022 Sep 28, 2022
OMG, why does this not exist? Honestly, if a box is created it shouldn't even Just be exposed to expressions, it should be exposed to the user.
Right now, the way it works is Kind of dumb. You can move the text box completely independently of the layer's position and anchor point. Well, that's all fine and all IF the user has access to the box's transforms as well. Shouldn't it work just like a shape? The shape Layer itself has transforms for the layer, but a rectangle shape within that layer Also has it's own properties like size, position, and an entirely new set of transforms just for that object.

This is how a paragraph text box should also work. It would be even better if you just let us wrap text inside a shape layer so it isn't even limited to just a rectangle. I mean, powerpoint has that. If powerpoint can do it, AE should be able to do it right? That's always a disappointing realization.
Translate
Report
Community Beginner ,
Sep 28, 2022 Sep 28, 2022
We need access to the bounding box of paragraph text by expression. If this were possible, we could flexibly change the width and height of paragraph texts directly. Furthermore, a precise setting of the size of the text box would be possible (currently, the box can only be set manually).
Currently we can only change the width of a paragraph text by scaling. But this also changes the size of the font. As a workaround we adjust the font size again: e.g. var txtFontSize = 100 * (100/transform.scale[0]);
All these workarounds cause complicated solutions.
Translate
Report
Explorer ,
Feb 15, 2023 Feb 15, 2023

Definitely need this!

Translate
Report
Community Expert ,
Feb 15, 2023 Feb 15, 2023

I could be wrong but there seems to be no way to access the size of a Text Box by expressions. That would be a nice feature request.

Translate
Report
Explorer ,
Nov 11, 2024 Nov 11, 2024

i agree, this would be great to have

Translate
Report
Community Beginner ,
Jan 07, 2026 Jan 07, 2026

@ShiveringCactus Would it be possible to provide a new link to the text file for your workaround, please? Bitly reports that the link is broken (I don't know if it actually is, or they just can't access Dropbox for whatever reason).

I only ask because I assume the code in the video doesn't incorporate the change you mention in the UPDATE of the video comments, with regard to soft returns. I did search for the Reddit post you mentioned in that update, but couldn't find it.


Alternatively, if you can just post what the code change for soft returns involves, I can add it to my transcript of the code from the video.

Translate
Report
Community Expert ,
11 hours ago 11 hours ago

Hi Wilson5E7C

 

Thanks for the heads up about the link.  I'll need to change it when I get a chance.

 

Here's the code from the text link:

var sourceText = text.sourceText;
var fontSize = sourceText.style.fontSize;
sourceText = sourceText.replace(/(\r\n|\n|\u0003|\r)/gm,"|");
textArray = sourceText.split(' ');

pixelWidth = effect("Width")("Slider");
charWidth = fontSize/2;

var txt = '';
var count = 0;

for (var i=0; i< textArray.length; i++) {	
	var word = textArray[i]+' ';
	if (word.indexOf('|') > -1) {
		word+'\n';
		count = word.length;
	} else {
	    count += word.length;
	    if (count*charWidth > pixelWidth) {
	        txt += '|';
		    count = 0;
	    }
    }
    txt += word;
}
txt.split('|').join('\n');
Translate
Report
Participant ,
5 hours ago 5 hours ago

I just relized it is a post in 2022.
man, I hope one day to see some ideas being applied to after effects😞

Translate
Report
Community Beginner ,
an hour ago an hour ago

Thanks very much @ShiveringCactus ! 

Translate
Report
Community Beginner ,
28m ago 28m ago

Actually, @ShiveringCactus , I did have another question about your expression.

 

After transcribing it from the video, I tried it out and discovered that it didn't work for me. After some painstaking debugging (in part using your tip on How to Get a Variable Value, so thank you for that, too!), I found the following issue, which is making me wonder how (or rather why) the code is working for you.

The issue is around these lines, particularly the second:

sourceText = sourceText.replace(/(\r\n|\n|\u0003|\r)/gm,"|");
textArray = sourceText.split(' ');

 

In the explainer video, in the Preview window, after the first line, the text in the Preview window is displayed as: 

"Hey, and welcome to Solvin'.||This one feels like it should…"

 Then after the second line, the text array is displayed as:

textArray[0] = "Hey,"
textArray[1] = "and"
textArray[2] = "welcome"
textArray[3] = "to"
textArray[4] = "Solvin'.||"
textArray[5] = "This"
textArray[6] = "one"
...

And this is the part where I can't figure out why it works that way for you. 'textArray' is made by splitting on spaces, but there's no space between "Solvin'.||" and "This". When I tried it with my own text, I got the equivalent of:

textArray[0] = "Hey,"
textArray[1] = "and"
textArray[2] = "welcome"
textArray[3] = "to"
textArray[4] = "Solvin'.||This"
textArray[5] = "one"
...

And then the code that handles looking for the separator character doesn't end up working because it adds a newline character to the end of any word with a separator in it, so (e.g.) textArray[4] would end up being 

"Solvin'.||This\n"

which is not ideal, since the newline is now in a different place from where it originally was.

In the video, that doesn't appear to happen in the demo, but I can't figure out why not. Any insights into this?

Translate
Report
Community Beginner ,
25m ago 25m ago
LATEST

UPDATE: I just realized why I had that problem. I caught what looked like a typo in your code, but it turns out to be the fix!

The line

 

word + '\n';

 

was originally written as 

 

word += '\n';

 

and that's what I had in my code. (I didn't notice until now that at 4:54 in the video, the line suddenly changes and the '=' disappears!)

 

As it is now (without the '='), that line doesn't actually do anything, because it doesn't assign the result of word + "\n" back to word. The only thing that happens in that if statement is that the count variable is updated.

That slightly affects the accuracy of the width calculation: the first line after each line break will be calculated to be longer than it actually is. But that will just make those lines a bit shorter which doesn't affect the overall functionality of the expression.

In any case, it's still a great solution to the original problem posted in this thread, so thanks for coming up with it and thanks again for the update.

Translate
Report