Where can I add python scene event callback?

   5588   2   2
User Avatar
Member
52 posts
Joined: Feb. 2016
Offline
In the example, you can run some code every time a new scene file is loaded after adding event callback. Can add the script in a separate file in HOUDINIPATH/scripts so it runs everything you start Houdini? I tried that but it doesn't seem to be working.

I am trying to write a script to save and load flipbook setting. I want it to load the settings when the file loads and save the settings to a node when file closes/saves


http://www.sidefx.com/docs/houdini/hom/locations.html#scene_events [www.sidefx.com]
http://www.sidefx.com/docs/houdini/hom/hou/hipFile.html#addEventCallback [www.sidefx.com]

import hou
def scene_event_callback(event_type):
if event_type == hou.hipFileEventType.AfterLoad:
hou.ui.displayMessage("The user loaded", hou.hipFile.path())
print("The user loaded", hou.hipFile.path())

hou.hipFile.addEventCallback(scene_event_callback)
User Avatar
Member
9374 posts
Joined: July 2007
Offline
as mentioned here
http://www.sidefx.com/docs/houdini/hom/locations.html#startup [www.sidefx.com]

place your event script in this file, so that it is added when Houdini session is run:
$HOUDINI_USER_PREF_DIR/python2.7libs/pythonrc.py

or if you are just looking for functionality to run stuff after you load any existing scene as you mentioned then as explained on the same page you can as well just include the code in:
$HOUDINI_USER_PREF_DIR/scripts/456.py
without adding any event
Edited by tamte - Feb. 28, 2018 04:31:06
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
52 posts
Joined: Feb. 2016
Offline
tamte
as mentioned here
http://www.sidefx.com/docs/houdini/hom/locations.html#startup [www.sidefx.com]

place your event script in this file, so that it is added when Houdini session is run:
$HOUDINI_USER_PREF_DIR/python2.7libs/pythonrc.py

or if you are just looking for functionality to run stuff after you load any existing scene as you mentioned then as explained on the same page you can as well just include the code in:
$HOUDINI_USER_PREF_DIR/scripts/456.py
without adding any event

Ah I see, if I want to install the script to other computers you need to append the code to their own pythonrc.py/456.py? So the main procedure is in another script file in “scripts” and I can have a callback function in pythonrc.py to call the main procedure after the scene is loaded?

Thanks for your reply!
  • Quick Links