Jump to content
Sign in to follow this  
dotcommer

AE Script for creating custom sized paragraph box

Recommended Posts

//Backstory

So I have to deal with putting legal at the bottom of endcards a lot. Each part of the legal comes from some company, and each is different from the other. Sometimes they change, and we don't find out, or we do, but we have tons of projects that used the older legal and its a laborious process to update the legal. So, I created a script that puts in an expression that references a text file on our network to put in the legal as needed, separated out by calling variables that have the different pieces of legal. Put them all together and bam, done.

 

 

//The Issue

Now, what I need to figure out is how to create a custom sized paragraph box, so the legal will wrap and format properly within a specified space. Does anyone know how to do that? I can't find anything thats close to what I'm looking for around the internet. I've already got the script putting in the expression into the text layer's "Source Text" property, now I just need to add to that script to create a custom sized paragraph box.

 

Any suggestions would be a great help! Thanks.

Share this post


Link to post
Share on other sites

im just getting into scripting now, so i'm not exactly sure what is doable.

 

are you able to set it to find a certain text layer, then duplicate it, and then fill with the source text?

 

if so, you could just set up the text paragraph box once, and have the rest based off that one.

Share this post


Link to post
Share on other sites

Its set up now so that you have to draw out the initial text box, then from there apply the script to it. I want to keep things more standardized, by forcing a specific size text box from the start.

Share this post


Link to post
Share on other sites

ahh... well i found this in the AE Scripting Guide....

Hope that helps.

 

good luck!

 

 

 

TextDocument boxText attribute

textDocument.boxText Description

True if a text layer is a layer of paragraph (bounded) text; otherwise false.

Type

Boolean; read-only.

TextDocument boxTextSize attribute

textDocument.boxTextSize Description

The size of a paragraph (box) text layer as a [width, height] array of pixel dimensions.

Type

Array of two integers (minimum value of 1); read/write.

Share this post


Link to post
Share on other sites

Hah! AE scripting guide? Where the hell is that?! I've been looking for something like that! I found the CS6 version online just now. Looks like this is what I need, now I just need to figure out how to call/create it, then put the expression in it. Thanks for your help!

Share this post


Link to post
Share on other sites

OK! So I figured it all out. I'll document what I did in case anyone out there has a similar need:

 

Generated a plain text document on our network. In that, I put all the different types of legal lines from various developers, companies, etc. Each one its own variable (eg: Company = 'legal lines of company.').

 

Then I created a .jsx script that creates a text layer with a custom sized paragraph box, and put in the expression that calls the text document above:

 

 

 

:: EDIT::

The code has been updated to reflect being able to have any comp selected when creating the text layer. Click here to go to the most recent code:

http://mograph.net/board/index.php?showtopic=27963&&do=findComment&comment=206463

 

 

 

Then dropped the script into the scripts folder of AE, called it from File>Scripts, and BAM, instant legal text. If the text needs to changed in any way, you can go into the text source expression and add or remove names of variables called in the text document.

 

 

WHEEEEE! Nothing like figuring out a complicated problem to get you going in the morning.

 

 

Any questions reply to this post, or PM me and i'll see if I can help you out. Thanks to krpdesign for the helpful resources!

 

 

Here are some other resources I took a look at to get me to where I needed:

http://blogs.adobe.c...ects-cs5-5.html

http://help.adobe.co...3906c6dea-7a26a

http://stackoverflow...n-after-effects

http://blogs.adobe.c...pting-Guide.pdf

Edited by dotcommer

Share this post


Link to post
Share on other sites

Oh, I should probably also thank codeacademy.com. A month ago I took their javascript course, and thats probably the only reason I was able to stumble my way through figuring this out. Check them out if you're interested in learning a coding language for free.

Share this post


Link to post
Share on other sites

Ok, got another issue that just came up. I have it set so that there has to be a composition in the project manager, that is at the top of the list, in order for this to work. How can I modify what I have so that it puts the new layer into the currently open composition? I'm assuming app.project.item(1); isn't right, because its selecting the first item in the project list. But I don't know what the proper syntax is for selecting the currently openend comp. Any help?

 

 

:: EDIT ::

 

Its about 12:10am at the time of this edit, and I think I've figured out the answer to the above question. I needed to identify not only the project, but the selected item in the project, and point to that when creating the text layer. This is accomplished by creating a variable "proj" with app.project. Then modifying the variable "theComposition" to call the active item of the project (proj.activeItem).

 

I have updated the code for the .jsx file below. Everything else stated earlier still stands:

 


{
var proj = app.project;
var theComposition = proj.activeItem;
var paraText = theComposition.layers.addBoxText([910, 140], "Legal");
var theTextLayer = theComposition.layers[1];
theTextLayer.property("Text").property("Source Text").expression = "/*Path of source text file*/ \n $.evalFile('/PATH/OF/TEXT/FILE/legal.txt') \n\n /*Add or remove names of legal as needed. Line breaks are created by adding \"\\r\" inbetween names*/ \n legal1+legal2+legal3";
}

Edited by dotcommer

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...