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

After effect scripting set text bounds

Community Beginner ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

I'm trying to generate text layers dinamically using a script.It works well.I coudn't find a way to contain the text without overflowing .As you can see in this image text is gone out of the composition view.

I trid to set a width but it doesn't work .Any idea about this.

var textLayer = comp.layers.addText(text);
textLayer.sourceRectAtTime(inPoint, false).width=1000;

TOPICS
Scripting

Views

151

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Oct 14, 2022 Oct 14, 2022

You will have to create paragraph text, not line-based text. Otherwise you have to do your own calculations to adjust size or wrap lines around. The text bounding box has nothing to do with this.

 

Mylenium

Votes

Translate

Translate
Community Beginner ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

Forgot to add image .this is the image 
Screenshot 2022-10-15 115851.png

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

This will adjust the font size to fit within a maximum width:

var text = "this is a long text testing scripting";
var comp = app.project.activeItem;
var maxWidth = comp.width;
var textLayer = comp.layers.addText(text);
var w = textLayer.sourceRectAtTime(textLayer.inPoint, false).width;
if (w > maxWidth){
	var sourceText = textLayer.text.sourceText;
	var textDoc = sourceText.value;
	textDoc.fontSize *= maxWidth/w;
	sourceText.setValue(textDoc);
}

Votes

Translate

Translate

Report

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
LEGEND ,
Oct 14, 2022 Oct 14, 2022

Copy link to clipboard

Copied

You will have to create paragraph text, not line-based text. Otherwise you have to do your own calculations to adjust size or wrap lines around. The text bounding box has nothing to do with this.

 

Mylenium

Votes

Translate

Translate

Report

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
Community Beginner ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

paragraph text ?
All could found is text document 
https://ae-scripting.docsforadobe.dev/other/textdocument.html.

Could you please refer me some docs

 

Votes

Translate

Translate

Report

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
Community Beginner ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

LATEST

Thanks It was really helpfull.

Votes

Translate

Translate

Report

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
LEGEND ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 15, 2022 Oct 15, 2022

Copy link to clipboard

Copied

You can also apply an expression to the layer scale, which scales the layer down when the source text goes beyond a certain size.

In the Community Library of Automation Blocks we have a tool which creates such expressions:

Votes

Translate

Translate

Report

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