ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Highlight some words in several text layers

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
liviu ispasoiu
Highlight some words in several text layers
on Jul 30, 2020 at 9:29:50 am

Hi, I have some text layers in a comp and I want the words at those numbers to be highlighted, as in the example below. A similar case can be found in this thread https://forums.creativecow.net/readpost/227/35912, but I was not able to make it work for several text layers. Can you please help me to fix it?



Return to posts index

Tomas Bumbulevičius
Re: Highlight some words in several text layers
on Jul 30, 2020 at 12:11:39 pm

Hey Liviu, just wondering - how sustainable is solution based on specific word index? And at the same time - how you will make sure indexes are correct?

Last but not least - how many text layers are to be considered in the scheme, or it can vary greatly?

Find out more:
Motion Graphics Design & After Effects Tutorials
On YT
On VH


Return to posts index

liviu ispasoiu
Re: Highlight some words in several text layers
on Jul 30, 2020 at 2:13:26 pm

Hi Tomas, thank you for your quick reply.
I want to use this with the ability to edit the content and control highlighted words in the essential graphics panel, for instance.
The number of words can vary depending on the content but with a fixed number of lines(rows) - let's say three. I could use a single text as a paragraph and that would be more convenient. But I can't really figure out how to animate each line individually. I also thought of looking up the name of the word instead of index. But, for example, if "the" appears in the text several times in the text, then it is highlighted each time it appears. A more advanced method is beyond me.


Return to posts index


Filip Vandueren
Re: Highlight some words in several text layers
on Jul 30, 2020 at 2:19:32 pm

This would work:

It's important that the animators are named "word highlighter".
The lines of text should be in order top to bottom in the timeline, so the layer index of line 1 should be less than that of line 2, etc.

An extra text-layer with the word-indexes separated by comma's is on layer named "indexes".

Expression Selector, based on Words

my_index_offset=0;
for (i=1; i < index; i++) {
try {
t = thisComp.layer(index-i).text;
test = t.animator("word highlighter");
my_index_offset += t.sourceText.value.trim().split(/\s/g).length;
} catch (e) {
// skip when "word highlighter" animator doesn't exist in previous layer
}
}

indexes = eval("[" +thisComp.layer("indexes").text.sourceText.value + "]");
indexes.indexOf(textIndex + my_index_offset) > -1 ? 100 : 0;




Return to posts index

Filip Vandueren
Re: Highlight some words in several text layers
on Jul 30, 2020 at 2:28:47 pm

Hmm.
Better replace that eval() with a split version, that's more robust:


my_index_offset=0;
for (i=1; i < index; i++) {
try {
t = thisComp.layer(index-i).text;
test = t.animator("word highlighter");
my_index_offset += t.sourceText.value.trim().split(/\s/g).length;
} catch (e) {
// word highlighter doesn't exist in previous layer
}
}

indexes = thisComp.layer("indexes").text.sourceText.value.split(",").map( s => parseInt(s));
indexes.indexOf(textIndex + my_index_offset)>-1 ? 100 : 0;




Return to posts index

liviu ispasoiu
Re: Highlight some words in several text layers
on Jul 30, 2020 at 2:40:01 pm

Hi Filip, this works very well. Thank you so much!


Return to posts index


Perry Sheppard
Re: Highlight some words in several text layers
on Jul 31, 2020 at 2:28:37 am

This might not be relevant, but if this would be used in a MOGRT, I associated a similar solution to empty csv data, so the highlighted words can be selected within Premiere.

Not sure how much of a performance hit this takes on the MOGRT (I'm still trying to track down why mine is so slow), but it works well and consistently.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]