Houdini 11 Houdini Object Model HOM Cookbook

Overview

This example shows how to load a hip file from a standard Python shell and inspect its contents. This particular example loops through all the object in /obj and prints out the positions of each of the points in the object.

Location

Supporting files for this example are in $HFS/houdini/help/hom/cookbook/print_hip_stats, also found in the cookbook/print_hip_stats directory of cookbook_files.tar.gz.

Running the Example

Run python2.5 print_stats.py to print out the contents of file_to_load.hip.

print_stats.py

#!/usr/bin/python2.5
import sys, os

# Adjust sys.path so it contains $HFS/houdini/python2.5libs.  Then we can
# safely import the hou module.  Importing this module will bring a Houdini
# session into the Python interpreter.
sys.path.append(
    os.environ['HFS'] + "/houdini/python%d.%dlibs" % sys.version_info[:2])
import hou

hou.hipFile.load("file_to_load.hip")

for object in hou.node("/obj").children():
    print "Points in", object.path()
    for point in object.displayNode().geometry().points():
        print point.position()
    print

# Release the Houdini Batch license.  If we wanted to, this script could
# continue running, but it would no longer consume a license.  When this
# script accesses the hou module again it will reacquire the license
# automatically.  (Note that only later versions of Houdini implement
# hou.releaseLicense()).
if hasattr(hou, "releaseLicense"):
    hou.releaseLicense()

See also