Dynamically changing Expressions

   908   4   0
User Avatar
Member
12 posts
Joined: May 2016
Offline
Hello dear community members, I am running into a topic and I can't wrap my head around. I am trying to build an channel expression dynamically, that is changing via user input. My idea is to bind specific elements of the expression into string attributes, that builds the complete expression (string attribute) depending on the input.

For instance the functions are separately, the locations, and every other element in it. Everything is coming together and should be pasted in a float channel (because the actual expression is referencing float data). But it does not seem to work, probably because of the attribute class being a string. But is there a way to tell Houdini like "evaluate the expression and convert it into its actual value"?

I am not sure, if this is how things can work inside Houdini, or maybe there is another way of doing such things? Putting an "atof" in front of the string expression does not working either.

Thanky you very much
User Avatar
Member
8589 posts
Joined: July 2007
Offline
try eval() [www.sidefx.com]
alternatively you can also do Python
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
12 posts
Joined: May 2016
Offline
Thanks @tamte. I've tried the eval() but unfortunately it's not working. I will give Python a try.
User Avatar
Member
8589 posts
Joined: July 2007
Offline
in python you can try evaluating your string as hou.hscriptExpression()
that way you don't have to flip you whole expression to Python
Edited by tamte - Jan. 6, 2023 16:05:35
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
12 posts
Joined: May 2016
Offline
Thank you very much .
  • Quick Links