Copy link to clipboard
Copied
In simple terms, I am just trying to change the source text on a left justified text object. However, it keeps resetting the justification to center, instead of just leaving it. Even when I try to set it to left as part of the process, it doesn't listen.
var textProp = myComp.layer('myTextObject').property("Source Text");
var textDocument = textProp.value;
textDocument.text = strings["name"];
textDocument.justification = ParagraphJustification.LEFT_JUSTIFY;
textProp.setValue(textDocument);
textProp.setValue(textDocument);
I was trying to setValue twice because I found a thread about a bug that made you do it twice, but that doesn't work either.
I was doing it this way, but switched to the above when I found the issue.
myComp.layer('myTextObject').property("Source Text").setValue(strings["name"]);
Any help? Thanks!
Copy link to clipboard
Copied
I can't duplicate your symptoms. If the text layer is already left justified, this is all I need to change the text (and remain left-justified):
var myComp = app.project.activeItem;
var textProp = myComp.layer('myTextObject').property("Source Text");
var textDocument = textProp.value;
textDocument.text = "test";
textProp.setValue(textDocument);
Dan
Copy link to clipboard
Copied
I figured out a workaround.
What I am doing is reading a text file and then putting the strings into the source text. So I am repeatedly "changing" the source text to the same thing over and over as I am working on it. Then I used the paragraph panel to make it left justified, and it kept resetting back to center. So I added the line to the script about justification, but it still didn't work. While experimenting, I changed the text to a different string, and it held the justification when I did setValue. But then, keeping that string the same and trying to change the justification to center as a test in the script didn't work.
I'm sure that made no sense. So basically, my workaround was to do this and changing the text to "" and then to the correct value seemed to force it to work:
var textProp = myComp.layer('myTextObject').property("Source Text");
var textDocument = textProp.value;
textDocument.text = "";
textProp.setValue(textDocument);
textDocument.text = strings["name"];
textDocument.justification = ParagraphJustification.LEFT_JUSTIFY;
textProp.setValue(textDocument);