Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

It's there any script API I can get each word position?

Community Beginner ,
Dec 05, 2021 Dec 05, 2021

I have a TextLayer with the text "Hello world, It's great".

It's there any script API I can get each word position?

TOPICS
Scripting
571
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 05, 2021 Dec 05, 2021

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 05, 2021 Dec 05, 2021

great, This document help me alot~~~

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 05, 2021 Dec 05, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 05, 2021 Dec 05, 2021

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2021 Dec 05, 2021

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.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2021 Dec 13, 2021

Great, Thankyou

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Dec 13, 2021 Dec 13, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 13, 2021 Dec 13, 2021
LATEST

It can really run, and it is very precise, thank you so much~~~~~~

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines