Supercharge Houdini with Python - Linköping...
Transcript of Supercharge Houdini with Python - Linköping...
Supercharge Houdini with Python
Fredrik LimsäterPartner / CTOFido Stockholm
Monday, November 9, 2009
Lesson 01 - Crowd Animation System
Very impressive results.
This is the strength of HoudiniReact = 1 weekHoudini = 4 hours
Monday, November 9, 2009
Lesson 02 - Houdini + Python
Dependant on that you go through the self studiesmaterial and Example files in Houdini covering DOPsand Python
Monday, November 9, 2009
Lesson 02 - Houdini + Python
Create and setup a RBD simulation using nothing but Python scripts. Create the basic structure without opening Houdini. Then create the DOP simulation by using a custom shelf tool that you script. Finish off by setup another shelf tool that render the sequence for you
Monday, November 9, 2009
Lesson 02 - Houdini + Python
But why would you create something this way?
License issues/cost $10 000 vs. $1 500
Unique geometry cachefor each shot
Monday, November 9, 2009
Lesson 02 - Houdini + Python
Problems or stuck?• [email protected]• What’s not working, what have you tried?
Monday, November 9, 2009
Houdini + Python
• docs.python.org/tutorial• http://localhost:48626/hom/intro• http://localhost:48626/hom/hou/• Houdini Learning Material
• HOM - Houdini Object Model• Accessing HOM• Hou Module• Simple Code examples
• Simple Dop setup example• Create RBD Objects• Shelf tools - Dop setup• Destroy it• Shelf tools - Render• Hython example
Monday, November 9, 2009
Houdini + Python
• HOM - Houdini Object Model• Lets you query information and control Houdini using python• Defines classes for the conceptual entities in Houdini
- nodes, parameters, keyframes, panes etc• Defines methods for manipulating entities
i.e. adding nodes , changing parameter values etc
Monday, November 9, 2009
Houdini + Python
How to access HOM• HOM can be accessed through the hou module• hou hooks directly into Houdini
Monday, November 9, 2009
Houdini + Python
Hou modulePython 2.5.4 (r254:67916, Jul 7 2009, 23:51:24) [GCC 4.2.1 (Apple Inc. build 5646)] on darwinHoudini 10.0.430 hou module imported.Type "help", "copyright", "credits" or "license" for more information.>>> import hou>>> hou<module 'hou' from '/Library/Frameworks/Houdini.framework/Versions/10.0.430/Resources/houdini/scripts/python/hou.pyc'>>>> dir(hou)['Attrib', 'Attrib_swigregister', 'BaseKeyframe', 'BaseKeyframe_swigregister', 'BoundingBox', 'BoundingBox_swigregister', 'Bundle', 'Bundle_swigregister', 'ButtonParmTemplate', 'ButtonParmTemplate_swigregister', 'ChopNode', 'ChopNode_swigregister', 'Color', 'Color_swigregister',...
Monday, November 9, 2009
Houdini + Python
Querying a node
>>> geo_node = hou.node("/obj/geo1")>>> geo_node<hou.ObjNode of type geo at /obj/geo1>>>> geo_node.path()'/obj/geo1'
Querying and setting node parameters
>>> tx=geo_node.parm("tx")>>> tx<hou.Parm tx in /obj/geo1>>>> tx.eval()0.0>>> tx.set(3.5)>>> tx.eval()3.5
Monday, November 9, 2009
Houdini + Python
Alt + Shift + P brings up the Python Shell in HoudiniGreat place to prototype your code / get feedback
Python Source Editor - Saved in the hip file (session)
Other places: shelf tools, Node parameters etc
Monday, November 9, 2009
Houdini + Python
Standalone Implementation
hython - python interpreter shipped with Houdini.Text based version of Houdini, automatically sets up the hou module
/opt/hfs10.0.243/bin/hyton
You can also use Linux’s Python interpreter
Monday, November 9, 2009
Houdini + Python
Code Examples
root = hou.node("/obj")geo = root.createNode("geo", "myGeoContainer")geo.moveToGoodPosition()
#delete default file nodefor child in geo.children():
child.destroy()
m = geo.createNode("merge", "collectSpheres")m.moveToGoodPosition()
sphere1 = geo.createNode("sphere", "mySphere")sphere1.moveToGoodPosition()sphere1.parm("tx").set("1")
sphere2 = geo.createNode("sphere", "mySphere")sphere2.moveToGoodPosition()sphere.2parm("tx").set("3")
m.insertInput(0,sphere1)m.insertInput(0,sphere2)m.setDisplayFlag(1)
Monday, November 9, 2009