Hi Andrei, AFAIK, you can’t set any paragraph options via scripting.
Here’s a dirty workaround using text-animators:
text animators with expression selectors based on characters skip over the “\r” character so it’s hard to detect them while keeping textIndex and the characters of sourceText in sync.
So to start, we’ll need an expression on the sourceText (or it can be done in your scripting) to replace every linebreak with an invisible zero-width space (unicode \0x200B) followed by a linebreak. This won’t alter anything of your layout, but the space does count as a character for the textIndex inside the expression selector.
So the expression for sourceText:
value.replace(/\r/g,"\u200b\r");
Next we need a Text-Animator:
- add a position property with value [0px, 10,000.0px]
- Add an Expression selector based on characters (and remove the default range selector)
- change the amount expression to:
txt = text.sourceText.value.replace(/\r+/g,"");
space_after = 90;
paragraphNumber = txt.substr(0,textIndex).split("\u200b").length-1;
paragraphNumber*space_after/100;
This first line strips out the linebreaks from the sourcetext so the javascript string’s indexes and the way after effects counts characters via textIndex line up.
space_after is the number of pixels you want each next paragraph to be pushed down.
The variable paragraphNumber counts how many times an invisible space is present, those represent a “countable” paragraph break.
The result of expression selectors needs to be a percentage between -100 and +100 of how much the position property gets applied, so using the set vertical change of 10,000 pixels means we can do an easy division to make for example 90 pixels translate to 0.9%
If you need more then 10,000 pixels (in this example more than 111 paragraphs) simply add an extra order of magnitude to both the position [100,000px] and the division in the expression (/1000)
Hope that works out.
Filip