OTLs

Oncreated script to set Output Transform of a OBJ level HDA


To set the output transform of an obj level HDA.

select the HDA and hit enter you will see a dropdown menu on the top bar of the viewport. from that menu you can select the node you want the "output transform from" 

but if u want to use a  specfic node's transform then you might need to setup an onCreated script which will set that drop-down selection whenever a new instance is created automatically

on the hda add an oncreated script and type the code below and change "OUTPUT_TRANSFORM" to whichever node you want


kwargs['node'].parm("outputobj").set("OUTPUT_TRANSFORM")


Append custom OTLS from a particular path

to add custom otls from a particular folder, without modifying already existing otls.

inside user-n/houdini17.5/ create a folder called package

Add the below code and modify the path 

{

    "env" : 

    [

        {

            "HOUDINI_OTLSCAN_PATH" : 

            {

                "value": "/path/to/the/otl_folder",

                "method": "append"

            }

        }

    ]

}



No Input error

HDAs with two inputs usually gives error when we don't connect second input. Two resolve this I have tried many ways but failed and did a research on internet couldnt find a simple solution , but there is a very simple solution available.

 In the very first tab of HDA type properties, > basic > minimum Inputs

set that to 1 .

Setting default for all parameters from current values

set the parameter values that you want to be default

in the Type Properties > go to the parameters tab > and look for the Gear Icon in the Existing Parameters section

click it and select Copy Defaults From Node

then click Apply/Accept

WARNING - this will apply all the current parameter values as defaults for the HDA - which is what you want but just be sure you set the right values

Disable when parameter

You have a parameter called “type” that is a choice with different options from 0 to 5. To disable a parm based on the value of “type” when it is 0 or 3, put this in to your parm's Disable field:

simple example would be

{type 0}


for "AND" operation

{paramerter1 == 1} {parameter2 == 1}


for "OR" operation

{parameter1 == 1 parameter2 == 1}

Accessing Radio Buttons

1 add folders , select all and set it to radio buttons

2 set the name of the first on to something like (folderType) other folders name will become disabled and automatically set to (folderType_1,folderType_2,....)

3 refference it using folderType1 (example : ch("../folderType1"))

simple text tutorial here

http://takavfx-note.tumblr.com/post/128059754537/radio-button-tab-menu-in-houdini

example hip in this thread

https://www.sidefx.com/forum/topic/13139/



HDA Callback script example

hou.pwd().hdaModule().myfunction(kwargs)

Keep your function in the scripts section of hda and
type in the callback script field

HDA menu script:


Hda Menu script is useful for populating the Ordered Menu parameter using a script.

For example i can collect available attributes in the incoming geo of HDA and then i can list them out in this menu to select one of them and create a visualizer for that attribute, lot of possiblilites.

Menu script  should return  a list of items, the  list can be like the following

["apple","Apple","samsung","Samsung","nokia","Nokia"]

You can notice i included the items twice, because  the 1st one is the actual name(to use in scripting) of the item and the second one is the label(for the user)

I couldnt find a better way but this works well for me so far


TIP: Keep the menu script in the Scripts section and just call it from the menu script, for simplicity.  so all code is in scripts section (HDA Module) .

try enabling  `use token as value` in case if doesnt work


HDA event handler modules

Hdas have the event handler moduels similar to the python module

This can be used to callback some  funtions based on certain events of the hda

Note: you cannot reference to the nodes directly like in the python module (hou.pwd())

but you can use the kwargs to point to the current hda or its parms like in the example below

node = kwargs["node"]

node.parm("version").set(1)