Python Snippets for Houdini - duartevictorino/Houdini GitHub Wiki
Lock transforms on selected nodes
for node in hou.selectedNodes():
node.parm("tx").lock(True)
node.parm("ty").lock(True)
node.parm("tz").lock(True)
node.parm("rx").lock(True)
node.parm("ry").lock(True)
node.parm("rz").lock(True)
node.parm("sx").lock(True)
node.parm("sy").lock(True)
node.parm("sz").lock(True)
print node.name(), "Locked!"
Change selected nodes to a red colour
nodes = hou.selectedNodes()
color = hou.Color([1,0,0])
for node in nodes:
node.setColor(color)
Check Environment Path
import os
for i in os.environ["PATH"].split(":"):
print i
Look for a specific name in all nodes in houdini
name = hou.ui.readInput("Type Name", buttons=('OK',"Cancel",))
if name[0] == 0 and len(name[1].replace(" ", "")):
print "START..."
for each in hou.node("/obj/").allSubChildren():
if name[1] in each.name():
print each.path()
print "DONE!"
Get the path to the current network location
local = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
localP = local.currentNode().path()
print localP
Find child nodes
import hou nodes = hou.selectedNodes()
for node in nodes:
#print (node,"\n")
for child in node.children():
print child
Basic display message UI with custom icon
hou.ui.displayMessage("Your Message", severity=hou.severityType.ImportantMessage)
Get the Network Editor Tab
hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)