Is there a vex command to execute a string variable?

   1189   4   1
User Avatar
Member
14 posts
Joined: Jan. 2009
Offline
Is there a vex command to execute a string variable?
Something like the exec() command in python.
User Avatar
Member
253 posts
Joined: July 2013
Offline
if you use backticks in the vex code you can reference a string parm who's value will be inserted into the code before vex is executed.
More code, less clicks.
User Avatar
Member
14 posts
Joined: Jan. 2009
Offline
Thanks for the response.

hmmm...I tried the following line in a attributeWrangle lop but no dice. Am I missing something?

string code = "usd_setvisibility(0, @primpath, 0);";
`code`;
User Avatar
Member
253 posts
Joined: July 2013
Offline
ylindqui
Thanks for the response.

hmmm...I tried the following line in a attributeWrangle lop but no dice. Am I missing something?

string code = "usd_setvisibility(0, @primpath, 0);";
`code`;

See screenshot, you make your to-be-executed string in a string parm and have a backtick-ed hscript expression insert it into the code. Instead of parms you can also pull a string/value out of a attribute or whatever, as long as you do it with an expression.
Anyways, Houdini will first run the expressions, after that the vex code that is then executed will internally looks like this:

printf("vex says: Hello\n");

f@someAttrib=0.35 * @ptnum;


Edited by Jonathan de Blok - March 21, 2023 04:10:43

Attachments:
Screenshot 2023-03-21 090022.jpg (160.7 KB)

More code, less clicks.
User Avatar
Member
14 posts
Joined: Jan. 2009
Offline
Executing a chs() expression does the trick. Thanks for the great explanation!
  • Quick Links