Adding an expression

Didn’t find how you can add an expression to any parameter, for example position?

Please let me know. How can I add expressions to scale, position, opacity…? I managed to add an expression only to effects, using loop “properties in the effect” > set expression. I can’t find it(

1 Like

Hi,
To save Alon some work and to be an active forum member…
Here’s how I do it.
Hope this helps… and you’re welcome to discuss further.
Nimrod

Set Expression.json (2.9 KB)

1 Like

Thank you @Zinim, really appreciate it!

1 Like

Thank you @Zinim! I didn’t consider using variables). This works, but you can only enter one line of text, what if the expression consists of 3-5 or more lines? I wonder if there is a solution?

@rctrance This question is very interesting and I had to think about it for a sec,
there is a solution for this but before the solution you should know that any expression should work also in one line of text, new lines is for reading the expression easily so the obvious solution is not to use multiple lines, for example:
“a = 5; b = 6; if (a < b){ 58} else {0}”
this is a valid expression with one line of text, you can convert your expression to one line too.

if you want to use multiple lines you can do it by first typing your expression as one line with special text for the new line for example-
“a = 5;\newLine\b = 6;\newLine\if (a < b){\newLine\58\newLine}\newLine\else{\newLine\0\newLine}”
now you can use a text variable action called “find and replace text element” to replace the “\newLine” with “\n” it will make a new line at every “\newLine”.
you should know that there is a property called “text element”, you have to set the text element to the “\newLine” because the “find and replace text element” will search for the text element value and replace it.
I created this example to apply expression with multiple lines to the opacity.
opacity expression.json (3.4 KB)

I will try to allow multiple lines in the next update.
Alon.

1 Like

Thanks @alonshemer! Yes, I understand. The fact that there is no way to immediately copy / paste a massive expression into a string is just a matter of convenience). I just wanted to clarify, just in case, maybe I’m missing something :). Your method is quite satisfying, the main thing is that it is possible to implement it! Well, if you manage to do this in future updates, it will certainly be great. Thank you for your time! :grinning: :+1:

thank you @rctrance, this kind of questions help making automation better and better, just wanted to let you know I already implemented it and this is very good addition to AT but it will have to wait until I finish other features I am am working on.

1 Like

@alonshemer This is great news! :handshake: Thank you Alon! If I have any interesting ideas, I’ll let you know :grinning:

1 Like

I didn’t take a look at Zinim’s automation, but I have been setting some very long expressions as animation presets and applying them via. the anim preset option in toolkit. Also means one loop can apply multiple expressions across different properties on each layer instead of having to make multiple loops to apply different expressions to different properties.

I also find if there is an error in the expression, I can easily work within the timeline to test it, re-save the preset and it automatically works on the next run. Some of my longer automations are getting a bit tough to navigate because of their size so this is a great option for the longer AT’s too.

1 Like