Hey Filip, been awhile! I finally got to test everything out in premiere. I gave the choice of color control for text, box and highlighted text and it works well ! It’s a bit slow (lots of calculations!) but it runs well as a mogrt !
I wanted to thank you cause I was really stuck with that one !
I use it to precompute some values in a text-layer, and then use the output of that textlayer as data in another expression.
If the result of a textlayer is just string we need to use, or a number, then you can simply get the value or value.parseFloat() of the textlayer, but in some cases you want to precompute a list of values or a list of key/value pairs.
a JSON type object is ideal for this.
So the expression on my precompute text layer ends with JSON.stringify(myStuff);
-> this turns the object or list of data I have into “readable/parseable” sourcecode including brackets, quotes,…
And where I want to use that information, I do JSON.parse(textlayer.text.sourceText.value) to “read” the generated sourcecode of the data object, and so the data becomes part of the expression.
So again to clarify: it doesn’t let another expression see inside the expression code of another property, but it’s a way to format the resulting string-value of a sourceText expression into something another expression can easily interpret.
Hi Filip and Yoan, I was looking through your thread because I need something quite similar to what you have done but a little different. Let me explain: I need to create a .mogrt for my colleagues where they can highlight multiple words in a text. And the idea is to have a text input where they write their text and another text input where they write the words they want to highlight. Here you can see that I succeed to highlight one word, but I can’t figure out how to highlight multiple words. here is the expression I use to highlight one word:
It does a few extra things so it also matches words regardless of case (everything is converted to lowercase), and it also matches a word when that is immediately followed by a punctuation mark (you may want to extend that list).
It uses Json parse and stringify, which can kind of be replaced with eval(),
and it also used styling of the sourceText (not possible in extendscript), to force the highlight marker to use a ceratin font, leading and fontsize, but if those are just set manually, it works equally well.