On this page |
Overview ¶
The Houdini Object Model (HOM) is an application programming interface (API) that lets you get information from and control Houdini using the Python scripting language. HOM replaces the functionality of Houdini’s previous command language, HScript.
In Python, the hou package is the top of a hierarchy of modules, functions,
and classes that define the HOM. The hou
module is automatically imported
when you are writing expressions in the parameter editor
and in the hython
command-line shell.
Which Python? ¶
Mac
On Mac OS X, Houdini uses the system’s Python.
Windows
On Windows, Houdini uses the version of Python installed with Houdini.
Linux
On Linux, Houdini does not look at $PATH
when trying to search and load the Python library. Instead it searches all the paths in $LD_LIBRARY_PATH
, then /lib
, and then /usr/lib
. If it can’t find a suitable Python library in the system, it uses the one in $HFS
. If your Python library is not in a standard location, you should add its directory path to $LD_LIBRARY_PATH
.
Subtopics ¶
Getting started ¶
-
You can write parameter expressions in Python instead of the default Hscript expression language.
-
Various places in Houdini where you can customize behavior using Python scripting.
-
How to write Python scripts for shelf/asset tools.
Next steps ¶
-
These examples demonstrate simple uses of the Houdini’s Python scripting API.
-
You can use HOM to store and retrieve arbitrary data on individual nodes.
-
Scripting Houdini from web pages
HTML pages viewed in the embedded browser can use a special JavaScript object to interact with Houdini.
-
You can programmatically find nodes using the same code as the Find dialog in the network editor.
Guru level ¶
-
You can control Houdini through HOM scripting from another Python session across the network.
-
Utility functions for extracting information from Alembic files.
Python viewer states ¶
-
Writing custom viewer states in Python
A viewer state controls how to interpret mouse movements, clicks, keys, and so on in the viewer.
-
Python state creating and editing nodes
How to implement a state that manipulates a node.
-
How to implement a state that does not work on a specific node, like a viewer or inspector tool.
-
How to allow the user to select geometry as part of working with your SOP node state or to select objects with your OBJ node state .
-
How to bind handles to your state and react to user interaction with the handles.
-
How to bind parameters to your state and react to parameter change.
-
How to display guide geometry in the viewport based on your state’s data and user interactions.
-
Python state user interface events
How to listen for and respond to direct UI input.
-
How to set up your state’s context menu and respond to user interaction with the menu.
-
How to set up your state to respond to drag drop actions.
-
How to make actions within your custom state undo-able.
-
Your Python state can display an info panel displaying hotkey and mouse usage hints, as well as current settings.
Python viewer handles ¶
-
Writing custom viewer handles in Python
Viewer handles are custom handles for changing parameters interactively.
-
How to render a Viewer Handle in the viewport with gadget drawables.
-
How to listen for and react to Viewer Handle events.