Houdini Python
· Houdini MOC · Python · #note/sink ·
TOC
Tips
To get available packages dir()
Snippets
Toggle update mode hotkey bind
# David Torno "Toggle Update mode Auto/Manual"
# Make a Shelf Tool and assign it a Hotkey, and place this code in the "Script" Tab...
import hou
mode = hou.updateModeSetting().name()
if(mode == "AutoUpdate"):
hou.setUpdateMode(hou.updateMode.Manual)
if(mode == "Manual"):
hou.setUpdateMode(hou.updateMode.AutoUpdate)
Camera lock hotkey bind
# David Torno "Toggle camera lock/unlock"
# Make a Shelf Tool and assign it a Hotkey, and place this code in the "Script" Tab...
pane = hou.ui.paneTabOfType(hou.paneTabType.SceneViewer)
view = pane.curViewport()
view.lockCameraToView(not view.isCameraLockedToView())
Get current camera
Python expression to get the path to the current viewport's camera
cd = hou.ui.curDesktop()
tab = cd.paneTabOfType(hou.paneTabType.SceneViewer)
vc = tab.curViewport()
return vc.cameraPath()
Buttons
Button callback python expression
Wired to a button, that rewrites values of the dictionary interface named groups
hou.pwd().parm('groups').setFromData({'dictionary': {'Eyebrows':'brows|eyebrow','Eyelashes':'eyelashes'}})
Button python code
Create a multistring field
Set language to Python
Use python callback:
exec(kwargs['node'].parm('pythoncode').eval()) # where python code is the name of the filed