Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Scripting: strange behavior of the textDocument Object ?

  • Scripting: strange behavior of the textDocument Object ?

    Posted by Jürgen Hackl on June 22, 2012 at 8:51 pm

    Hi,
    can anyone tell me, why the following script doesn’t work correctly. I copy/pasted it straight from the AE Scripting Guide CS6. Some of the values, but not all of them are assigned to the source text. It seems like it only works for the text-string and the justification … (My System: OSX 10.7.4, AE CS6 german version)

    thx
    J.

    var myComp = app.project.items.addComp(“Text”,1000,1000,1,10,25);
    var myTextLayer = myComp.layers.addText();

    textProp = myTextLayer.property(“Source Text”);
    var textDocument = textProp.value;
    myString = “Happy holidays!”;
    textDocument.resetCharStyle();
    textDocument.fontSize = 100;
    textDocument.fillColor = [1, 0, 0];
    textDocument.strokeColor = [0, 1, 0];
    textDocument.strokeWidth = 2;
    textDocument.font = “Times”;
    textDocument.strokeOverFill = true;
    textDocument.applyStroke = true;
    textDocument.applyFill = true;
    textDocument.text = myString;
    textDocument.justification = ParagraphJustification.CENTER_JUSTIFY;
    textDocument.tracking = 50;
    textProp.setValue(textDocument);

    Jürgen Hackl replied 14 years, 1 month ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Fredley

    June 25, 2012 at 4:28 pm

    I think it’s because you need to declare the text string before you set all of its properties.

    Cut and paste the “textDocument.text” line so the script reads:
    myString = "Happy holidays!";
    textDocument.text = myString;

    Then the rest remains the same.

    It looks like a possible type in the AE Scripting Guide.

  • Dan Fredley

    June 25, 2012 at 6:54 pm

    Actually here’s the script that works for me:
    var myComp = app.project.items.addComp("Text",1000,1000,1,10,25);
    var myTextLayer = myComp.layers.addText();

    textProp = myTextLayer.property("Source Text");
    var textDocument = textProp.value;
    myString = "Happy holidays!";
    textDocument.text = myString;
    textProp.setValue(textDocument);
    textDocument.resetCharStyle();
    textDocument.fontSize = 100;
    textDocument.fillColor = [1, 0, 0];
    textDocument.strokeColor = [0, 1, 0];
    textDocument.strokeWidth = 2;
    textDocument.font = "Times";
    textDocument.strokeOverFill = true;
    textDocument.applyStroke = true;
    textDocument.applyFill = true;
    textDocument.justification = ParagraphJustification.CENTER_JUSTIFY;
    textDocument.tracking = 50;
    textProp.setValue(textDocument);

  • Jürgen Hackl

    June 28, 2012 at 6:39 am

    Hi Dan,

    yes, that was the problem. Thank you very much.

    Jürgen

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