HDA class plan.

HDA class.

Date Created:Sunday March 11th, 2007 05:18 PM
Date Modified:Saturday August 02nd, 2008 04:17 PM


* What is the difference between HDA and OTL?

* Operator Type Library(OTL)
* Houdini Digital Asset(HDA)
* OTL is the file format
* OTL's contain HDA's

* What are some benefits of using HDA's?

* Ease of use
* Ease of creation
* Reuse
* Help others in learning
* Facilitates production changes

Create: Basic light HDA

* Promoting parameters directly from a node.
* Promoting parameters from Parameter Browser inside of Type Properties.
* Making a parameter from scratch, and using `ch()` to link parameters.
* Creating a persistant Handle.

DEMO: Impact Chop Lights

* This HDA can look at any DOP network, and create lights based on impacts from RBD Objects.
* Use of hidden parameters for "dynamic" dopfield() expressions

Create: Curve / Sweep HDA:

* Load MakeCurves.hip file. Jump into Curve_Example Geometry.
* Select all nodes except the two curve SOPs at the very top. ( input_curve & input_profile )
* Shift + C to create a Subnet
* Right Click, and Create Digital Asset.
* Use 2 minimum inputs and 2 for maximum inputs.
* Operator Name is used for the default name for new nodes, and to classify the type of HDA.
* Operator Label is used when adding a node from the tab menu.
* Create a name for otl file, specify a path and click Accept.
* Use naming in the input/output tab of Type Properties to aid artists. ( profile & curve )
* Create two string parameters, profile and curve.
* Change the Curve SOPs coords parameters so they are referencing the newly created parameters:

     /obj/MyHDA/profile_curve/coords:       `chs("../profile")` 

     /obj/MyHDA/base_curve/coords:          `chs("../curve")`

    * These will be hidden parameters in the HDA.

* The following script will make an array out of all the points in a given SOP.
* The null SOPs, which are at the top of the subnet, inherhit the points from the subnet Input.
* It does a for loop on all the points from the source input, using point() to get position data.
* We can put this script in an event script.
* In Type Properties, navigate to the Events tab, and choose OnInputChanged.
* $arg1 is the path to the HDA when using Event Scripts.


    set OP = $arg1/curve

    set zed=""

    for i = 0 to `npoints("$OP")-1`


        set zed = $zed `point($OP,$i,P,0)`,`point($OP,$i,P,1)`,`point($OP,$i,P,2)`


    opparm $arg1 curve ("$zed")

    set OP = $arg1/profile

    set zed=""

    for i = 0 to `npoints("$OP")-1`


        set zed = $zed `point($OP,$i,P,0)`,`point($OP,$i,P,1)`,`point($OP,$i,P,2)`


    opparm $arg1 profile ("$zed")

* Create a reload button, with the following callback for recooking when not changing inputs:

    source opdef:.?OnInputChanged `oppwf()`

* Promote switch, resample, and carve controls.
* Hide curve and profile parameters.


* This HDA uses arrays to generate curves, and procedurally generates geometry.
* Uses unsynced HDAs within HDAs. ( Use of hidden parameters is better practice! )
* Create nodes with Hscript using opadd and callbacks.
* Use of scripts within HDA's and managing them.
* HDA controller to control other HDAs and manage them.

    # referencing a script from an HDA:

    source opdef:Object/HDA_Name?scriptname

    # referencing a script from within and HDA:

    source opdef:.?scriptname

CREATE: Dynamic dropdown menu listing mantra nodes with a menu script.

* This dropdown menu will allow us to control any mantra nodes dynamically.
* Create a string parameter, change the name to "node", Label to "Select Node:"
* Go to the Menu tab in Type Properties.
* Toggle on Use Menu, as well as Menu Script.
* Menus require two values, Token and Label.
* Token is the value you would get when using chs().
* Label is what you see when you are navigating through the menu items.

    # Basic menu script to understand using two values:

    # One value for Token, and the second value for Label:

    echo 1 on

    echo 0 off

    # Menu script using foreach():

    foreach x(`("object light shadow")`)

        echo $x $x


* Use expressions like strreplace() on the label to make menus look nicer
* Use the run() expression to return the output of Hscript commands.
* Use the following code in the menu script:

    # Lists all nodes of type "mantra", within the path "/out"

    foreach x(`run("opfind -p /out -t mantra")`)

        echo $x `strreplace($x,"/out/","")`



* Create a string parameter, change the name to "parameter", Label to "Select Parameter:"
* Go to the Menu tab in Type Properties.
* Toggle on Use Menu, as well as Menu Script.
* Use the following code:

    # Lists all the parameters of the selected node:

    set OP = `chs("node")`

    foreach z(`run("opparm -l $OP *")`)

        echo $z $z


* Create a string parameter, change the name to "value", check off Label.

    # This is used as a callback on the parameter string to "get" the values:

    opparm `oppwf()` value ("`chsraw(chs("node") + "/" + chs("parameter"))`")


    # This is used as callback on the value string to "give" the values.

    opparm `chs("node")` `chs("parameter")` ("`chsraw("value")`")

* The difference between `chs()` and `chsraw()`:

    echo `chs("mantra1/picture")`


    echo `chsraw("mantra1/picture")`


* Use source command along with chs() to source a script depending on what you select from pulldown.

    source opdef:.?`chs("button")`

* Disabling parameters

    # if parm is 0 or parm1 is 0 and parm2 is 1

    { parm 0 } { parm1 0 parm2 1 }

DEMO: Generate Instance HDA

* This HDA allows a user to use instancing with objects, shaders, lights and shadows.
* Easy access to all attributes for instances, allows for managing instances. * The set-up is very complex for instances, yet only takes a few steps.
* Uses Hscript to generate Instances.

DEMO: Mantra Manager HDA

* This HDA allows a user to manage all mantra nodes in a project.
* It will create a project directory structure on disk based on the subnet stucture of your mantra nodes.
* Also this HDA will generate IFD scripts for rendering IFD's from the shell with the mantra command.
* How to give and get parameters.
* Dynamic pull-down menus
* Storing shell scripts within HDA, and using HDA to run them

* Adding contents to HDAs and saving contents to disk from HDAs.


    # this defines the table/label of the current otl

    set table = `optypeinfo(oppwf(),"T")`

    set label = `optype(oppwf())`

    set OTL   = ${table}/${label}

    # this deletes a section named array

    otcontentdelete $OTL array

    otcontentdelete Object/MyHDA array

    # this adds a section named array from $TEMP/$file

    otcontentadd $OTL array $TEMP/$file

    otcontentadd Object/MyHDA array $TEMP/array.txt

    # this does a loop an all the content in an HDA and dumps it to disk.

    foreach content(`run("otcontentls $OTL")`)

        otcontentsave -o $TEMP/$content $OTL $content


    # this would make a file executable and run it, if you dump a shell script.

    unix chmod + x $file

    unix ./$file

    # pass an argument into a script

    unix ./$file $arg1

* Use opscript, it will help you!

    # this echos the commands necessary to re-create the operator.

    opscript nodename

    # if node contains networks, recursively applies to the entire operator hierarchy.

    opscript -r nodename

Other Example HDAs

*Globe, and 3d Text