def func(): print 'Hello World!' """ pseudocode: if ch('../null1/tx') changed: func() """
Execute Python code only if parameter is changed
1957 1 1- Garry_cg
- Member
- 7 posts
- Joined: Dec. 2017
- Offline
- Enivob
- Member
- 2625 posts
- Joined: June 2008
- Offline
It is kind of a two-step process. You have to specify a callback for the parameter you want to monitor. The callback script defaults to the Hscript language so you have to remember to click the H icon and change it to the Python icon or this code will not work.
So you define a call to your function and can even pass along hard coded constant variables. You don't get the value of your parameter in the call back, only the reference to where you can find the value.
In your python script use something like this to get the value.
exec(hou.node("/obj/pythonscript1").parm('python').eval());MyFunction("/obj/CHANGE_PARAMETER_HERE","my_parm")
In your python script use something like this to get the value.
def MyFunction(passedNodeName, passedParmName): print "Node [%s] called me." % passedNodeName n = hou.node(passedNodeName) if n != None: p = n.parm(passedParmName) if p != None: print "With a value of [%s]." % p.eval()
Edited by Enivob - Aug. 29, 2018 15:27:10
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
-
- Quick Links