leytonian Posted October 9, 2016 Share Posted October 9, 2016 Hi I want to be able to run python code on each frame if and only a certain node is selected. I assume this must be a hou.session thing but the my hou.session scripts do not run on each frame if I am seeing it correctly. They are just some globally acccesed code. Basically I am looking for a frame change hook that runs in the session. thanks Quote Link to comment Share on other sites More sharing options...
edward Posted October 9, 2016 Share Posted October 9, 2016 What type of things would it do? I think the easiest way is to display a Python SOP that uses hou.frame(). If it needs to be not visible, it can just output empty geometry. Quote Link to comment Share on other sites More sharing options...
leytonian Posted October 9, 2016 Author Share Posted October 9, 2016 edward I want to invoke some stuff in img context per frame. Quote Link to comment Share on other sites More sharing options...
Atom Posted October 9, 2016 Share Posted October 9, 2016 (edited) Just drop down a python node at the OBJ level and put your code there. It does not really matter which context you are in when the code runs. Using Python you can reach into other contexts, for instance to force cook a node in the img context. hou.node('/img/comp1/default_pic').cook(force=True) There was an old trick I read about that by simply referencing the variable $F in back ticks, inside a python node, would cause it to evaluate every frame. I am not sure how reliable that is, however. The concept was that because you were using an hScript variable replacement that some kind of evaluation would happen after the fact. curframe = `$F` Basically Python updates while manually scrubbing the time line are not very realistic unless it is the simplest of manipulations. As you grow your scene, your FPS will drop to the floor. But you can always guarantee your python script will run every frame at render time by making it force cook in the Pre-Frame Render script event of any ROP that processes frames. (such as a Mantra node) hou.node('/obj/my_python_node').cook(force=True) Edited October 9, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
leytonian Posted October 10, 2016 Author Share Posted October 10, 2016 Thanks guys. I will try the suggestions. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.