HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Using Creation Scripts

Introduction

There are several support files that can accompany an operator. The most common one is an icon, but there are also command, geometry, and help files. These files are placed in various subdirectories of a Houdini configuration directory, which for local users is typically

$HOME/houdini10.0/

but on Mac it can be

$HOME/Library/Preferences/houdini/10.0/

So, for example, the dynamic libraries that implement custom operators are placed in the dso subdirectory:

$HOME/houdini10.0/dso/

Icon Files

You can supply an icon file whose name corresponds to the table and name of the new operator. Then, by default, Houdini will use that icon for that operator. For example, in if the new object operator name is "hdk_lamp", then the corresponding icon is "OBJ_hdk_lamp.png". The custom icon files should be placed in the config/Icons subdirectory of the Houdini configuration directory:

$HOME/houdini10.0/config/Icons/

You can also explicitly assign an icon to an operator with OP_Operator::setIconName() and then the icon file does not need to correspond to the operator name.

Geometry Files

Sometimes you may wish to supply a custom geometry to represent your new object operator. The geometry files are stored in the geo subdirectory

$HOME/houdini10.0/geo/

By default, Houdini looks for geometry files in this subdirectory, if it has not found it in other default places such as $HFS/houdini/geo.

Command Files

When a new operator node is instantiated in Houdini, Houdini searches for the default creation script and invokes it if it finds one. The script that corresponds to the operator has the same file name as the operator. For example, the script file "hdk_lamp.cmd" corresponds to the "hdk_lamp" operator. The object operator creation scripts are placed in the scripts/obj/ subdirectory:

$HOME/houdini10.0/scripts/obj/

Example of Script Files

The toolkit sample comes with an example of the creation scripts for the OBJ_Lamp.C source code. The example is very simple because it only registers a new operator type with an old factory function and an old parameter list owned by the OBJ_Light node:

However, there is also an hdk_lamp.cmd file that comes with this example.

# hdk_lamp.cmd: a default script run when a lamp object is created
if ( "$arg1" != "" ) then
set saved_path = `execute("oppwf")`
opcf /obj/$arg1
opadd file file1
opparm file1 file 'deflamp.bgeo'
oplocate -x 0.18 -y 3.0 file1
opcf $saved_path
endif

Houdini will invoke this script for each newly instantiated node of type "hdk_lamp". The "hdk_lamp" operator is exactly the same as the standard "light" which is implemented by OBJ_Light, but the creation script configures it in its own way. The main difference is the new representation geometry, defined in deflamp.bgeo that also comes with this example. It is a very simple example script, but the hdk_lamp.cmd could be more complex if it set different parameter values or created a larger SOP network within the lamp node.