20.08.2015 Views

TECHNICAL PAPER Building Tools for Houdini 9

TECHNICAL PAPER Building Tools for Houdini 9 - Digital Cinema Arts

TECHNICAL PAPER Building Tools for Houdini 9 - Digital Cinema Arts

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

▪▪▪▪▪▪Oft-used operations (such as caching to disk) are at the root folder levelFrequently changed parameters in a Folder are at the topParameters often found together (such noise controls) should stay together and be named as expectedFigure 13 - Smoke: Heavy parameter interfaceWrite the Tool ScriptOnce the Digital Asset functions as expected from the TAB Menu, it can be turned into a tool.The first thing you should do be<strong>for</strong>e you write a script is make sure that you really need to write a script. Theautomatic tools are generated by the defaulttools.py module (found in $SHS/scripts/python), and generallyjust call xoptoolutils.genericTool(). Each optype has its own toolutils module with a genericTool function. Evenif the tool you are writing is not really an optype-tool (i.e. it’s primary purpose is not to just lay down a newnode), you may not have to write as much code as you think. Get familiar with the toolutils module, and thexoptoolutils modules appropriate to the tool you are writing. There are lots of handy convenience methods, orat least sample code to get you started.Common things to do include:▪▪▪▪▪▪▪▪▪▪Detect contextDetect selectionsPrompt the user <strong>for</strong> inputGrab the viewport position and write to custom translate parametersCTRL-click Shelf to immediately add tool to sceneDetecting Context to determine what <strong>for</strong>m the tool should take is important when your tool can be usedeither at the Object, SOP or any other level. . The assumption is that the current selection drives the viewportcontext. If we know what context the viewer is in, we know our selection type.There are a few ways to write this part of your script. The most common is to follow the <strong>for</strong>mat as used in theDelete tool on the shelf:0001 import toolutils0002 # find out curr context16 | <strong>TECHNICAL</strong> <strong>PAPER</strong> Rev 1.0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!