Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions After Effects Script problem with text layers

  • After Effects Script problem with text layers

    Posted by Gerg Tolcs on September 7, 2015 at 2:32 pm

    Hi, sorry it’s my first post, it’s not about expressions, but scripts, i hope, it’s ok.

    So, I’ve got a script some parts work, some parts don’t work. There’s no errors, it runs but doesn’t do some parts.

    I want to collect 6 text layers and want to store and manipulate theme in a JSON I post the generator loop and write in a comment – works or doesn’t work.

    I’m new in AE, but I’m ok with javascript. I use the document of adobe for CS6, and I use CS6. Any ideas? thanks!

    for (var layerNum = 0; layerNum < 6; layerNum += 1){
    myTextLayers['word' + layerNum] = {};

    myTextLayers['word' + layerNum].layer = mainComp.layers.addText(); // works
    myTextLayers['word' + layerNum].layer.name = 'word' + layerNum; // works

    myTextLayers['word' + layerNum].property = myTextLayers['word' + layerNum].layer.property('Source Text');
    myTextLayers['word' + layerNum].value = myTextLayers['word' + layerNum].property.value;

    alert( myTextLayers['word' + layerNum].value); //empty

    myTextLayers['word' + layerNum].value.text = 'my little text ' + layerNum; //works

    myTextLayers['word' + layerNum].value.font = config.textSettings.font; //doesn't work
    myTextLayers['word' + layerNum].value.fontSize = config.textSettings.fontSize; //doesn't work
    myTextLayers['word' + layerNum].value.applyFill = config.textSettings.applyFill; //doesn't work
    myTextLayers['word' + layerNum].value.fillColor = config.textSettings.fillColor; //doesn't work
    myTextLayers['word' + layerNum].value.justification = config.textSettings.justification; //doesn't work
    myTextLayers['word' + layerNum].value.tracking = config.textSettings.tracking; //doesn't work

    alert( myTextLayers['word' + layerNum].value); //just 'text' is here

    myTextLayers['word' + layerNum].property.setValue(myTextLayers['word' + layerNum].value);

    myTextLayers['word' + layerNum].layer.position.setValue([0,layerNum*100]); // works
    }

    Gerg Tolcs replied 10 years, 8 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    September 7, 2015 at 2:52 pm

    The value of text property must be a TextDocument (see Guide).
    You have to create one ( var t = new TextDocument() ), assign its attributes, then set it as the value.

    Xavier

    Edit : Sorry, i misread your post. Ignore !

  • Gerg Tolcs

    September 7, 2015 at 3:10 pm

    Hi, thank you the answer! I’m not sure, what happens 🙂 but if I add the text before the value settings, its solve the problem.

    So,

    …value.anything =

    works after

    …value.text = ”;
    …property.setvalue(…value.text)

    it needs a character in the line to do anything. maybe it’s the same, AE generate the TextDocument, when I add a character?

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