set expression script

Hi to all,
I’m tried create a set expression since code.
the tool have do a set expression on text size parameter of a text node on the project.
I mean, if the user press “ok” on the gui this automatly put a code on size parameter like this:

I can find anything about this in the docs.

if someone can help me I’ll great greatfull.

Thanks so much and sorry for my bad english.

This is probably the doc you elready found
https://natron.readthedocs.io/en/rb-2.3/devel/PythonReference/NatronEngine/AnimatedParam.html#NatronEngine.NatronEngine.AnimatedParam.setExpression

The problem with your example seems to be the multine syntax. You might solve it with a single line syntax of the if then condition (didn’t tested) and intermediate variables.

I tested manually setting the “multi line” option before running the script and it didn’t worked

@devernay a “isMultiLine” boolean parameter seems to be needeed in the “setExpression” function

Hi Bonalex01, thanks for your reply, have been it help to me.
I having been testing with this code and accept the multiline:

but the problem now is when I add a line with a sentencie “if”, I do not get the set expression, simply don’t work.
I know is rare, but I try only line with “if” sentence and don’t add it.
I will continue research.
Thanks again.
Regards.

Hi, I found the problem. I try manually and set expression give me a error with the value return with “ret”.
I have complete the sentence just like I show you here:

setExpressionNatron

I think the problem was that I write if sentence the ret was out the scope of main code, when try intrepreted the code ret was null.
Whatever, it’s working now. :grin:

Thanks for taking time to post the solution. Tricky indeed :slight_smile: