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

SOURCERECTATTIME FOR STRING

New Here ,
Mar 09, 2022 Mar 09, 2022

Copy link to clipboard

Copied

I need to use sourcerectattime().width for only a particular string in a layer source text.

 

E.g. if the text is Thisismytext**Here you go. So i want to be able measure the width of "Thisismytext" and "Here you go" separately within the same source text. How can i achieve this.

TOPICS
Expressions , Scripting

Views

196

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 ,
Mar 09, 2022 Mar 09, 2022

Copy link to clipboard

Copied

This is not directly possible. The text will have to be treated with string operations and the processet output piped into a second text layer with identical formatting. From that you can glean all the info you need and piece the text together by calculating positions and that. Since it's convoluted and never actually looks the same due to typographical calculations needing to consider a ton of factors for rendering text it would be best if you just structured your text suitably from the outset and format it manually.

 

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 Expert ,
Mar 10, 2022 Mar 10, 2022

Copy link to clipboard

Copied

As Mylenium says, this is only possible, if you set the text of a layer to exactly the text whose size you want to measure. If your goal is to split the text into these parts, the API of TextExploder could be an option:

https://mamoworld.com/article/textexploder-scripting-api

 

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
Enthusiast ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

LATEST

It IS possible to measure parts of a text layer using text animators and some time-based trickery. If you use a Character Value animator to change the characters you don't want to measure into whitespace characters, sourceRectAtTime() will only measure the bounding box of the characters that remain unchanged. Now, obviously this makes part of your text invisible, but the important thing to remember is you can measure the sourceRect at any time, including times your text isn't onscreen, even including times outside the running time of your comp.

 

I typically do this by having the Character Value animator only blank out the extraneous characters at a negative time value, i.e. before the start of the comp. Then I feed that time into sourceRectAtTime() and it gives me just the dimensions of just the characters I want to measure.  I use this trick all the time to do things like measuring individal lines, words, or characters, and theres no reason it wouldn't work to measure a particular phrase.

 

If this sounds like something you'd like help working out in more detail, please let me know.

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