Anson Savage
AnsonSavageBYU
About Me
Connect
LOCATION
Not Specified
ウェブサイト
Houdini Engine
Availability
Not Specified
Recent Forum Posts
Forcing Python node to recook when its dependencies change 2023年5月23日22:21
Jonathan de Blok
If I take the hip file you posted and add this line the the "set_new_focal_lenght" node it works fine and prints updates.#dummy comment to trigger update `optransform( chs("../camera_path") )`
Also, I added this line and it does exactly what I need it to do! Very interesting.
Forcing Python node to recook when its dependencies change 2023年5月23日22:01
Jonathan de BlokHey, I love this info, this is super helpful!
If I take the hip file you posted and add this line the the "set_new_focal_lenght" node it works fine and prints updates.#dummy comment to trigger update `optransform( chs("../camera_path") )`
But again, this is solution is not going to win any prizes and as Graham suggest doing this though attributes is better way.Image Not Found
And btw.. a much overlooked feature in the wrangle/expression nodes is in the wrangle's src edit window context menu->reference->scene data' where you can generate vex to get you started on retrieving all sorts of scene data:Image Not Found
I'm experiencing two issues: if I have the camera reference the new focal length in a detail attribute, this creates infinite recursion (I guess when the detail attribute changes, the camera changes, which causes the Python node to cook again which recooks the node the computes the new focal length...)
Also, thanks for the tip on using the scene reference data! Looking at the code that makes it up it appears that it still references the entire camera SOP and would thus recook the node even if only the focal length changes. Any tips on how to avoid this?
Thanks!
Anson
Forcing Python node to recook when its dependencies change 2023年5月22日20:37
graham
Thanks for the hip file! From looking at it, you're running into essentially an infinitely recursive situation, though Houdini is silently not doing anything or warning you about it...
Because you're evaluating the focal parm in your Python SOP and then down the chain trying to set that parm again, it's causing a bunch of issues. At least in the hip file posted you're not actually doing anything with that "current" value anywhere, just printing for I'm guessing debug purposes? If you get rid of that (in the get data node and compute nodes) the problem mostly solves itself. That said, using that other Python SOP to set a parameter value during cook is also a very bad idea. A more proper solution would be to have the focal parameter on the camera just use a detail() expression to grab the computed value from the compute node.
You should also be able to easily grab the transform matrix in VEX without doing any Python at all using optransform() to get the matrix and then getting the position and rotation matrix from that instead of relying on the Python node to provide it.
Ah, that makes sense! So maybe I can have some Python code that puts the detail() expression into the camera when the node is enabled. I was hoping to make it able to push values (instead of requiring the camera to pull values), but I see what you're saying now, I guess pushing values would make it change and this would call the first Python node again creating an infinite loop.
Thanks for the hints!
Anson