Dynamic text Replacement in text layers

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
caderial
Posts: 12
Joined: Mon Jul 08, 2024 8:00 pm

Dynamic text Replacement in text layers

Post by caderial »

I am in need of assistance, I am seeking to programmatically access a text layers properties panel and change the text dynamically via scripting that is input in the txt input section. For instance I want to replace the text in that "Enter Text" Field with something new programmatically. Is there a way to do this Via Lua? Ideally also be able to change fonts or other styles scaling,. leading, kerning.. all the properties in this panel for any given text layer?
Thoughts, suggestions?

Image
User avatar
hayasidist
Posts: 3830
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: Dynamic text Replacement in text layers

Post by hayasidist »

I don't think it's possible to do what you want in the way you describe.

There is a function https://mohoscripting.com/methods/scrip ... serttext-2 that will allow you to create text on a text layer or allow you to add text to a vector layer.

But the text and its attributes in a text layer are not animatable. Similarly, having created shape(s) on a vector layer, the attributes in the parameter block have done their job - but this does give you shapes that you can animate.

So (e.g.) if you wanted to change the colour of a word at some point in the timeline, you'd need to animate the colour of the relevant Shape(s) that had been previously created - e.g. animated fills / gradients / ....
Similarly, changing a font would mean creating two versions of the text then switching between them in some way -- e.g. using a switch layer; or animating layer opacity; or masking to reveal / hide...

==

Speaking personally, I very rarely use Moho text -- Most of the time I create text in an external program and that text goes directly into a compositor as pngs or png sequences as appropriate where I can scale / position / ... or play with its colours ... / apply transitions ...

Sometimes, I might import png into Moho if I want the sort of (bitmap) animation that moho offers better than the compositor (e.g. warping using mesh / bones...).
Post Reply