Hello! I am not understanding why in this context of expressions in python I cannot read the state of the on/off button, I have tried several functions but they crash the machine in an infinite loop.
My idea is to read the state of the button to activate or deactivate the 'Bypass' button of a node.
Thanks in advance!
Read Toggle Button with Python Expression
1002 4 1-
- nazimba
- Member
- 21 posts
- Joined: Oct. 2019
- Offline
-
- ObeidaZakzak
- Member
- 123 posts
- Joined: Dec. 2019
- Offline
Hello,
A parameter expression should be used to set that parameter's value. You are attempting to read this parameter's vlaue in an expression that's is meant to set it, so no wonder that it's finishing with an infinit loop.
Take a look at parameter callbacks instead as they sound to fit your need of triggering an event when clicking on the toggle parm.
A parameter expression should be used to set that parameter's value. You are attempting to read this parameter's vlaue in an expression that's is meant to set it, so no wonder that it's finishing with an infinit loop.
Take a look at parameter callbacks instead as they sound to fit your need of triggering an event when clicking on the toggle parm.
Houdini Pipeline Supervisor @ TAT Studio
-
- vikus
- Member
- 234 posts
- Joined: May 2017
- Offline
Hi, an expression always has a return value, since you feed the same parm with its value you will get an infinite loop.
If you have more than one line of code, you need a return statement, and you don't need to import hou inside expressions, that's done by default. You can simply write pwd().parm('...')...
If you have more than one line of code, you need a return statement, and you don't need to import hou inside expressions, that's done by default. You can simply write pwd().parm('...')...
-
- nazimba
- Member
- 21 posts
- Joined: Oct. 2019
- Offline
ObeidaZakzak
Hello,
A parameter expression should be used to set that parameter's value. You are attempting to read this parameter's vlaue in an expression that's is meant to set it, so no wonder that it's finishing with an infinit loop.
Take a look at parameter callbacks instead as they sound to fit your need of triggering an event when clicking on the toggle parm.
Thank you very much ObeidaZakzak. I really didn't know. These are the details that appear as one begins to navigate the deep waters of Houdini.
viklc
Hi, an expression always has a return value, since you feed the same parm with its value you will get an infinite loop.
If you have more than one line of code, you need a return statement, and you don't need to import hou inside expressions, that's done by default. You can simply write pwd().parm('...')...
Wow! This is key to operating with expressions in this context. Thank you very much viklc!
Thank you very much everyone, this forum is great.
-
- nazimba
- Member
- 21 posts
- Joined: Oct. 2019
- Offline
For anyone interested in creating a single line Callback Script to turn nodes on or off from a Toggle Button, here is the code tested and working.
What I did was create a list of nodes and evaluate it with the Lambda function to avoid external files or the unnecessary creation of HDA containers, so this way I can choose which nodes to target.
Thanks to ObeidaZakzak's suggestions!
Python script:
Long live to Houdini!
.....
What I did was create a list of nodes and evaluate it with the Lambda function to avoid external files or the unnecessary creation of HDA containers, so this way I can choose which nodes to target.
Thanks to ObeidaZakzak's suggestions!
Python script:
(lambda bypass_value: [hou.node(path).bypass(bypass_value) for path in hou.parm("/obj/SCENE_001/CTRL/bypassNodes").eval().split()])(hou.parm("/obj/SCENE_001/CTRL/bypass").eval())
Long live to Houdini!
.....
Edited by nazimba - July 3, 2024 11:49:18
-
- Quick Links