Pythonhoudini
From DreamsteepWiki
DOCS
http://www.sidefx.com/docs/houdini9.5/hom/hou/Node
Change a nodes name
nod.setName('mynoder')
ASCODE
hou.Node.asCode( hou.node("/obj/keiths_network"))
HOU module
list all py modules in houdini
dir(hou)
KEYFRAMES (UNTESTED)
hou.Keyframe()
hou_keyframe.setTime(1.70833)
hou_keyframe.setValue(0)
hou_keyframe.setSlope(0)
hou_keyframe.setAccel(0.333333)
hou_keyframe.setExpression("bezier()", hou.exprLanguage.Hscript)
hou_keyed_parm.setKeyframe(hou_keyframe)
RUN AN HSCRIPT COMMAND
hou.hscript('opls')
DIR (NO PYTHON COM EXISTS FOR THIS)
hou.hscript('opls')
OPLAYOUT (NOT WORKING)
a.layoutChildren()
SET A TRANSLATION VALUE
b.parm('tx').set(3)
access a parameter (translation x in this example)
tx = g.parm('tx')
VALUE = tx.eval()
change a parameter
import hou
g = hou.node('/obj').createNode('geo')
tx = g.parm('tx')
tx.set(3.618)
print tx.eval()
NAVIGATING HOUDINI
hou.cd('/img')
hou.pwd()
hou.cd('..')
SHOW ORIGIN
a.showOrigin(True)
parenting (linking on obj level)
a = hou.node('/obj').createNode('geo')
b = hou.node('/obj').createNode('geo')
b.setInput(0,a)
LIST CHILDREN
for n in hou.node("/obj").children():
print n.name()
make selectable
hou_node.setSelectableInViewport(True)
set visibility
n.setDisplayFlag(True) n.setDisplayFlag(False)
clear the scene
hou.hipFile.clear()
add your own command folder to the PATH
import sys
sys.path.append('/path/to/hou_pyhon_scripts')
make a node type geo in /obj
g = hou.node('/obj').createNode('geo')
select a node
query selected
for n in hou.selectedNodes():
print n.name()
#########OR###########
for n in hou.node("/obj").selectedChildren():
print n.name()
load a scene and render a rop
#!/usr/bin/python2.5
import sys
sys.path.append(os.environ['HFS']+“/houdini/scripts/python”)
import hou
try:
hou.hipFile.load(sys.argv[1])
except hou.LoadWarning, e:
print e
except hou.OperationFailed:
sys.exit(“Could not load “ + sys.argv[1])
rop = hou.node(“/out/OUT”)
rop.render()
get the path of the node
path = g.path()
list all nodes in scene
import hou
def print_tree(node, indent=0):
for child in node.children():
print " " * indent + child.name()
print_tree(child, indent + 3)
# Press Enter to finish the definition
print_tree(hou.node('/'))
python equivalent of opscript command
xx = hou.node('/obj').createNode('geo')
CODE = xx.asCode()
print CODE
PARMTUPLES
hou_parm_tuple = hou_node.parmTuple("t")
hou_parm_tuple.set((0, 0, 0))
hou_parm_tuple.setAutoscope((True, True, True))
hou_parm_tuple.lock((False, False, False))
>>> # hou.Parm tuples correspond to parameter groupings:
>>> t = g.parmTuple('t')
>>> t
<hou.ParmTuple t in /obj/geo1>
>>> tuple(t)
(<hou.Parm tx in /obj/geo1>, <hou.Parm ty in /obj/geo1>, <hou.Parm tz in /obj/geo1>)
>>> t.eval()
(3.5, 0.0, 0.0)
>>> t.set((1.0, 2.0, 3.0))
>>> t.eval()
(1.0, 2.0, 3.0)

