I have some code that calculates a value that changes per time sample and is commonly used by artists to drive parameters on their nodes (think something akin to $FF). While storing the function on hou.session and then referencing it in the parameters is an option, I'd much prefer to provide an environment variable or something else equally convenient to make life easier for the artists.
Does anyone know how to drive an environment variable via Python and have it update per time sample on any parameters that reference it? Also, what is the best way to trigger the function to update the variable once every time sample?
Can python drive parameters via dynamic env variable?
1597 3 2-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
-
- Enivob
- Member
- 2659 posts
- Joined: June 2008
- Offline
You can place code inside the frame change event, if that's what you mean by time sample?
Try adding a callback.
https://www.sidefx.com/docs/houdini/hom/hou/playbar.html [www.sidefx.com]
Try adding a callback.
https://www.sidefx.com/docs/houdini/hom/hou/playbar.html [www.sidefx.com]
Using Houdini Indie 20.5
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
Windows 11 64GB Ryzen 16 core.
nVidia 3060RTX 12BG RAM.
-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
That does sound promising. So I can update the environment variable there, but how would I then update the parameters that are using that variable. I tried hou.hscript("varchange") as recommended @ https://www.sidefx.com/forum/topic/58619/, [www.sidefx.com] but that didn't seem to work: at least not in LOPs. Any idea why that would be?
Edit: I just realized that the update issue might be because I was trying to trigger the function from a parameter, so it might be possible it was signaling the varchange after the parameters using the variable had already been updated. I'll test and report back.
Edit: I just realized that the update issue might be because I was trying to trigger the function from a parameter, so it might be possible it was signaling the varchange after the parameters using the variable had already been updated. I'll test and report back.
Edited by Ashen - June 5, 2023 11:53:21
-
- Ashen
- Member
- 78 posts
- Joined: May 2018
- Offline
So using the playbar callback https://www.sidefx.com/docs/houdini/hom/hou/playbar.html [www.sidefx.com] seemed to work perfectly at first (my issue was indeed due to the fact that varchange doesn't work properly when called from a parameter). However I've discovered that ROPs do not trigger the callback, and so the environment variable does not update during caching or rendering.
Any ideas if there is a callback I can use that is run both by the viewport and by background processes like ROPs?
Any ideas if there is a callback I can use that is run both by the viewport and by background processes like ROPs?
-
- Quick Links

