SceneInitScripts
From Odwiki
Scene Initialization Scripts
When you launch a Houdini session it may be necessary to perform various activities based on whether a new scene is being created or a scene file is loaded. You might also wish to define various functions and constants that will be needed throughout the session.
123, 456 Scripts
When Houdini is started without a hip file, it runs the 123 script. The 456 script is run whenever a hip file is loaded or the session is cleared. These scripts, either Hscript or Python, can be used to do things such as setting up new scenes with default assets or verifying versions and dependencies of scene assets in existing files.
These scripts, named 123.[cmd/py] and 456.[cmd/py] can exist inside the main scripts/ folder in the HOUDINI_PATH. When searching through the HOUDINI_PATH for these scripts Houdini will execute the first matching file it encounters. It will give precedence to a .py file over a .cmd file when they exist in the same directory.
Whenever implementing your own 123.py script it is recommended the last line be a call to source the default 123.cmd script as it is responsible for setting some basic Houdini aliases and variables.
hou.hscript("source 123.cmd")
Examples:
- The default new scene init script is $HFS/houdini/scripts/123.cmd
- A custom script: $HOME/houdiniX.Y/scripts/456.py
PythonRC
A purely Python module, pythonrc.py, can be automatically imported upon launch. This module allows you to import other modules, define functions or constants, as well as other general operations using Python code. This script is only run whenever Houdini launches.
The pythonrc.py file must be placed inside either scripts/python/ or a python2.Xlibs/ directory inside the HOUDINI_PATH.



