Design a site like this with
Get started

[Code] Houdini Python (4)

Learning Python, so here is jotted-down notes that might be useful, part 3.


* 1 – Python sops

  • technically running in detail* context, executing code only once
    hou.pwd() == hou.node(‘ . ‘)
    hou.Node => class referred to all nodes in Houdini
    hou.Geometry => class referred to all sop 3d geometry in Houdini
  • geo.points() => return all points in the geometry, used better when looping all items in the list
    geo.iterPoints()[11] => used better when grabbing just one item in the list, fetching one item from the theretical list that only generate when you call the list
    this grabbing method had similar ones for prims
    global attributes is also know as detail attribs
  • geo.addAttrib(type, name, default_value,….) => create an attrib, refer to documentation for more info
    some useful functions:
    hou.Geometry class: boundingBox()
    hou.Point class: position(), number()
    hou.Vertex class: linearNumber(), number()

* 2 – hou.ui module

  • hou.ui.panes().tabs() => return the pane tabs in the ui
  • Methods in hou.PaneTabs() module: interact directly with the ui
    splithorizontally() – splitvertically()
    splitSwap() – splitRotate()
  • hou.ui.panes()[1].tabs()[0].type() => return the type of pane tab
    hou.ui.panes()[1].tabs()[0].close() => close tab
    things to notice: title, text, buttons, severity, close_choice, default_choice
    severity types: represented by icons of the popped up message;
    help: shows explanation below text; details: shows more details when user click ‘Show details’
    hou.severityType.Fatal will force close Houdini
  • Functions frequently used: hou.ui._______
    readInput() => read input that user type in
    readMultiInput() => requires message, input labels, also have password input field
    selectFromList() => requires choice, allow exclusive select
    selectFromTree() => requires choice, using “/” to have hierachy
    selectParm() / selectParmTuple()
  • Status line
    hou.ui.setStatusMessage(‘Hello World!’) => calculate progress by using percentage of the progress (enumerate, divide by the length of the list?)
  • Update viewport mode
  • Clipboard
    getTextFromClipboard() => str

* 3 – Render Scripts:

  • Use a semi-colon “;” to seperate lines of code in a one-liner parameter
  • pre-render: runs before the rop runs
    pre-frame: runs once per frame, even before the 1st frame
    post-frame: runs after caching each frame to memory
    post-write: runs after frame is written to disk
    post-render: runs once after the all frames are cached
  • hou.hipFile module, used frequently for saving files (and backups)
  • exec function is a Python-native function, just like import
    exec hou.pwd().parm(‘create_file’).eval() => execute and evaluate parameter ‘create_file’ which is where we put our Python script in


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: