ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Scripting: strange behavior of the textDocument Object ?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jürgen Hackl
Scripting: strange behavior of the textDocument Object ?
on Jun 22, 2012 at 8:51:21 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);


Return to posts index

Dan Fredley
Re: Scripting: strange behavior of the textDocument Object ?
on Jun 25, 2012 at 4:28:00 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.


Return to posts index

Dan Fredley
Re: Scripting: strange behavior of the textDocument Object ?
on Jun 25, 2012 at 6:54:49 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);


Return to posts index


Jürgen Hackl
Re: Scripting: strange behavior of the textDocument Object ?
on Jun 28, 2012 at 6:39:03 am

Hi Dan,

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

Jürgen


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]