+ HOUDINI PYTHON

Note to self on Python in Houdini.

Create a python shelf tool

# camera
render_cam = hou.node('/obj').createNode('cam')
render_cam.setName('render_cam_HD')
render_cam.parm('resx').set(1920)
render_cam.parm('resy').set(1080)

# mantra
mantra_driver = hou.node('/out').createNode('ifd')
mantra_driver.setName('mantra_render_HD')
mantra_driver.parm('camera').set('/out/render_cam_HD')
mantra_driver.parm('vm_renderengine').set('pbrraytrace')

Run a python script from a node

Create a null and edit the param interface. To make it less cluttered we can hide copy and cache input. Then we add a string and a button. We give the string parameter the name code and make it a multiline string and set the language to Python. On the button we set the callback script to Python and type the following expression in the callback script line edit:

exec hou.node('.').parm('code').eval()

If we click the button the python code that we eneterd in the string parameter text input filed will be executed.