Copy link to clipboard
Copied
I have a TextLayer with the text "Hello world, It's great".
It's there any script API I can get each word position?
Copy link to clipboard
Copied
Not sure what you are asking. You simply use the normal AVLayer properties as laid out in the scripting guides. I suggest you look up this stuff.
https://ae-scripting.docsforadobe.dev/
Mylenium
Copy link to clipboard
Copied
great, This document help me alot~~~
Copy link to clipboard
Copied
Unfortunately not. I think the best you can do is use sourceRectAtTime() and keep semding different things through a text layer, measuring the size of all the text, the size of a single line of text, and the size of each word then figuring it out from that. Not ideal but certainly possible.
Copy link to clipboard
Copied
I thought of a way to create two Texts, one to display all, and the other to display only the portion of the all words....and use the sourceRectAtTime API to get the width.....and compare the two position and width , you can get the word position easily
Copy link to clipboard
Copied
If you want to split a text via scripting, note that my script TextEploder also comes with its own scripting API such that you ca remote-execute it with other scripts.
Copy link to clipboard
Copied
Great, Thankyou
Copy link to clipboard
Copied
You can do this using text animators and expressions, plus a little time-based trickery.
Add a Character Value text animator to your text with a Range Selector. Set "Start" to -1, "End" to 0, and on the "Offset" property apply the following expression:
-Math.ceil(time)
Under the "Advanced" property group, set "Units" to "Index", "Based On" to "Words", "Mode" to "Subtract". Set the "Character Value" property to 32 (which is the space character) and also apply this expression to the "Character Value" property:
if(time >= 0) 0
else value
Once you have set all this up, what you will get is a text layer that displays normally for times greater than or equal to 0 seconds, but that will only display individual words at negative times (it blanks out everything but the word at time = -index). Now if you call sourceRectAtTime(-1) you will get the source rectangle of the first word. -2 will give you the second word, and so on.
This can also work for lines, just change "Based On" to "Lines" and then you can access each line's source rect at the time corresponding to its negative index.
Copy link to clipboard
Copied
It can really run, and it is very precise, thank you so much~~~~~~