Learning Python, so here is jotted-down notes that might be useful, part 3.
LOG 4
* 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 - SCRIPTED UI
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._______
displayMesseage()
readInput() => read input that user type in
readMultiInput() => requires message, input labels, also have password input field
selectFile()
selectFromList() => requires choice, allow exclusive select
selectFromTree() => requires choice, using “/” to have hierachy
selectFromNode()
selectMultipleNodes()
selectParm() / selectParmTuple()
selectAttrib()
selectColor() - 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
hou.ui.setUpdateMode(mode) - Clipboard
copyTextToClipboard(text)
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