Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Creating a textbox and align it to an area via extendscript

  • Creating a textbox and align it to an area via extendscript

  • Emre Mutlu

    June 28, 2022 at 7:05 pm

    Hi there,

    How can i create a text box in a composition and center it to specific area? (Like the example in the attachment)

  • Filip Vandueren

    June 30, 2022 at 8:01 pm

    Hi Emre,

    to my knowledge it’s still not possible to create textbox-textlayers via scripting, only paragraph text.

    You can only check if a textlayer is a text-box and get its dimensions/position, not set the properties.

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

  • Dan Ebberts

    June 30, 2022 at 9:04 pm

    Scripting does have a command specifically for creating box text, so you could do something like this to create the text and center the anchor point within the resulting text (which will be centered within the comp):

    var myComp = app.project.activeItem;

    var myTextLayer = myComp.layers.addBoxText([300,500]);

    var mySourceText ="ADBE Text Properties").property("ADBE Text Document");

    var myTextDoc = mySourceText.value;

    myTextDoc.text = "This is a line of text for my new text box.";

    myTextDoc.justification = ParagraphJustification.CENTER_JUSTIFY;


    var myRect = myTextLayer.sourceRectAtTime(0,false);

    var newAP = [myRect.left + myRect.width/2, + myRect.height/2];"Anchor Point").setValue(newAP);

  • Filip Vandueren

    June 30, 2022 at 11:22 pm

    That’s great. I don’t script often and have always missed this. Thanks Dan.

  • Emre Mutlu

    July 1, 2022 at 7:34 am

    Thank you very much guys. I was having trouble to change style of the text box which i’ve added but figure it out too. I’m adding my code here too. Looks like you should use TextDocument object to modify the style of text box.

    var titleLayer = mainComp.layers.addBoxText([1250,500]);

    // Title Text Properities ///////////////////////////////////////////

    var titleTextDoc = new TextDocument(“Test Text”);“Source Text”).setValue(titleTextDoc);

    var textProp =“Source Text”);

    titleTextDoc = textProp.value;

    titleTextDoc.fontSize = 50;

    titleTextDoc.text = title;

    titleTextDoc.fillColor = [1,0,0];

    titleTextDoc.justification = ParagraphJustification.CENTER_JUSTIFY;


Viewing 1 - 5 of 5 posts

Log in to reply.

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