Copy link to clipboard
Copied
Under paragraph menu, there is an option to align text to the left, center or right. There is also an option to justify text.
How can this me done with expressions or Extendscript?
I noticed that if I set Anchor point to the top left, additional text added on the same line is left aligned. If I set anchor point to the left-center, all the lines added in the future are left justified, but current text remains as it is. Align options under paragraph don't move anchor point and also work for the text already typed.
I guess you could save the text, delete it, move anchor point, paste the text back and move anchor point back where it was to achieve the same effect. But there is probably a better way?
These options are not accessible with expressions. They are part of the text panel and stored in teh source text compound keyframes, not as separate properties. therefore the only way to address them programmatically is to use scripts. Check the script help for the various properties. Otherwise one would simply use text animators to create the illusion.
Mylenium
Copy link to clipboard
Copied
These options are not accessible with expressions. They are part of the text panel and stored in teh source text compound keyframes, not as separate properties. therefore the only way to address them programmatically is to use scripts. Check the script help for the various properties. Otherwise one would simply use text animators to create the illusion.
Mylenium
Copy link to clipboard
Copied
Hi Tim Sx
With Extendscript you can justify the following way:
var myLay = yourTextLayerGoesHere;
var txtProp = myLay.property("Source Text");
var txtDoc = txtProp.value;
txtDoc.justification = ParagraphJustification.CENTER_JUSTIFY; // change here to the value you need based on the list below
txtProp.setValue(txtDoc);
The justification can be any of the below options:
ParagraphJustification.LEFT_JUSTIFY
ParagraphJustification.RIGHT_JUSTIFY
ParagraphJustification.CENTER_JUSTIFY
ParagraphJustification.FULL_JUSTIFY_LASTLINE_LEFT
ParagraphJustification.FULL_JUSTIFY_LASTLINE_RIGHT
ParagraphJustification.FULL_JUSTIFY_LASTLINE_CENTER
ParagraphJustification.FULL_JUSTIFY_LASTLINE_FULL
I hope this helps.
Cheers
Henrique
Copy link to clipboard
Copied
Thank you both. I am learning so much.
Copy link to clipboard
Copied
In Ae ver. 2020 some new text properties were added in the expressions menu:
https://helpx.adobe.com/after-effects/using/expressions-text-properties.html
I still can't find a way to control the paragraph direction via code 🤔
Am I missing something or is it still not possible?
Copy link to clipboard
Copied
Maybe not exactly OP's question, but the answer to my problem was in this link. Explaining here in case anyone comes across this thread in the future.
I was building a mogrt and needed to be able to change the justification of a text box while keeping all the rest of the style properties.
From the helpdoc:
// To return the values of both the style and the actual Source Text at time (short hand) var sourceTextProperty = thisComp.layer("MAIN TEXT").text.sourceText; var newStyle = sourceTextProperty.getStyleAt(0,0); newStyle.setText(sourceTextProperty);
I made 4 duplicates of my text layer (left, right, center, and justify all justifications), and chose the centered layer as my control. I manually set the left and right layers to left and right justification and copied this expression into the source text for the left, right, and all layers:
// To return the values of both the style and the actual Source Text at time (short hand)
var sourceTextProperty = thisComp.layer("Body Copy_Center").text.sourceText;
var newStyle = sourceTextProperty.getStyleAt(0,0);
newStyle.setText(sourceTextProperty);
Then I added a dropdown control to a null, and wrote a quick if/else on the opacity of each layer to turn them on or off depending on which justification the end user wants. That's the control I put in the final mogrt.
For the left align layer it looks like this (where "1" is the dropdown menu option for left align):
align = thisComp.layer("Controls").effect("Body Justification")("Menu");
if(align == 1){100}
else{0};
Hope this helps someone!
Copy link to clipboard
Copied
This is currently in the beta verson of AE 2025.
Paragraph styling in Expressions is now available for testing and feedback. Try it now in After Effects (Beta).
In addition to text style attributes, there are also paragraph attributes. These can only be applied to the entire Text layer. The paragraph attributes are only available in After Effects (Beta).