Python expression / callback problem

   1149   2   0
User Avatar
Member
33 posts
Joined: Jan. 2015
Offline
Hi,
I'm following a tutorial that sets up a button to execute some python code once.
Cannot get the button to execute the code at all. However, when I enter “edit expression” and Apply, it does turn into executable code however it runs many times over automatically.
Attached file has both example nodes.

Thanks in advance!

Running 17.0.493 Indie on Mac 10.13.6

Attachments:
python_test.hiplc (192.5 KB)

User Avatar
Member
8599 posts
Joined: July 2007
Offline
you callback is:
hou.node(".").parm("python_code").eval()
which will merely return the python code as string

you have to do something like this
exec(hou.node(".").parm("python_code").eval())
to have it executed
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
33 posts
Joined: Jan. 2015
Offline
Amazing! Thank you Thomas.
  • Quick Links