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

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

Community Beginner ,
Dec 05, 2021 Dec 05, 2021

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?

TOPICS
Scripting

Views

329

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

great, This document help me alot~~~

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

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

Votes

Translate

Translate

Report

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

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.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Great, Thankyou

Votes

Translate

Translate

Report

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 13, 2021 Dec 13, 2021

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

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