Represents the definition of a houdini digital asset (HDA).
A digital asset definition defines a node type and exists inside an otl file. The node type is implemented in terms of other nodes wired together inside a subnet. These nodes inside the subnet are called the definition’s contents.
An otl file contains one or more digital asset definitions, and installing an otl file installs all the definitions in the file. When a digital asset definition is installed, the node type it defines is added to Houdini. Note that you can access an HDADefinition without installing it.
A digital asset’s algorithm is determined by the nodes inside it. To edit those nodes you create an instance of the digital asset, unlock it, modify the contents, and save the definition. New digital asset instances are normally locked, meaning that they are read-only, and they automatically update when the asset’s definition changes. An unlocked instance is editable, does not update when the definition changes, and you can save its contents to change the definition.
To unlock a node, select Allow Editing of Contents or call hou.Node.allowEditingOfContents. To save the contents of an unlocked node to the definition, select Save Operator Type or call hou.HDADefinition.updateFromNode. To revert an unlocked instance back to the last saved definition and change it back into a locked instance, select Match Current Definition or call hou.Node.matchCurrentDefinition.
See also hou.hda and hou.HDAOptions.
Methods
| addParmFolder | Adds a folder to this node type’s parameters. |
| addParmTuple | Add a parameter tuple to this node type’s parameters. Houdini places the new parameter at the bottom of the parameters in a particular folder. |
| addSection | Create a new section with the specified contents. If a section already exists with this name, changes the existing contents to the new contents. Note that the contents may contain binary data. Also note that section names may contain '/'. |
| comment | Return the user-defined comment string. It is up to you how you use the comment; it is not used by Houdini. |
| copyToHDAFile | Copy this definition into an otl file. |
| description | Return the description for this definition’s node type. Houdini uses this description for user interface elements such as the TAB menu. This description is also called the operator label in Houdini. |
| destroy | Uninstall this definition and delete it from the otl file. Any node instances of this asset will warn that they are using an incomplete asset definition. |
| embeddedHelp | Return the help text embedded in the digital asset. Return an empty string if no embedded help exists. |
| extraFileOptions | Return a dictionary containing the extra options attached to sections in the asset’s definition. For example, event handler scripts such as OnCreated are stored as sections inside the asset, and extra metadata in this dictionary determines whether Houdini runs these scripts as Python as as Hscript. |
| extraInfo | Return a string storing extra information about the asset definition that isn’t stored elsewhere, like the representative node, guide geometry, whether default parameters are hidden, etc. |
| hideDefaultParameters | Return whether the parameters that are common to nodes types in this node type category are hidden or not. For example, nearly all objects have common translation, rotation, scale, etc. parameters, and object level digital assets have these parameters by default. If hidden, though, these parameters are still there but are not displayed to the user. |
| icon | Return the name or path of the icon for this definition’s node type. Note that Houdini uses its search path to locate icons, so you do not need to pass in a full path. |
| isCurrent | Return whether this definition is the one currently in use by Houdini. |
| isInstalled | Return whether this definition is installed in Houdini. |
| isPreferred | Return whether this definition is preferred. |
| libraryFilePath | Return the path to the otl file containing the digital asset’s definition. |
| maxNumInputs | Return the maximum number of inputs that node instances of this digital asset can have. Return a number greater than 4 if this node type can accept an unlimited number of inputs. |
| minNumInputs | Return the minimum number of connected inputs that node instances of this digital asset can have. If these inputs are not connected, the node will generate an error. |
| modificationTime | Return the time when the definition was last modified. This time is returned as a POSIX timestamp, such as is returned by time.time(). |
| nodeType | Return the node type defined by this digital asset. Raises hou.OperationFailed if the digital asset is not installed. |
| nodeTypeCategory | Return the node type category (e.g. Objects, SOPs, DOPs, etc.) for the node type defined by this digital asset. See hou.NodeTypeCategory for more information. |
| nodeTypeName | Return the name of the node type defined by this digital asset. Raises hou.OperationFailed if the digital asset is not installed. |
| options | Return a hou.HDAOptions object for the options stored in this digital asset. See hou.HDAOptions for more information. |
| parmTemplateGroup | Return the group of parm templates corresponding to this asset definition’s parameter interface. |
| removeExtraFileOption | Remove an entry in the dictionary of extra file options. See hou.HDADefinition.extraFileOptions for more information. value may be a bool, integer, float, string, or sequence of 2, 3, or 4 numbers. |
| removeParmFolder | Remove an empty folder from this node type’s parameters. |
| removeParmTuple | Remove a parameter tuple from this node type’s parameters. |
| removeSection | Remove an existing section. Only remove sections that you explicitly added. Do not remove the special sections that Houdini uses to store the contents of the digital asset definition, or Houdini will generate errors or strange side effects. |
| replaceParmTuple | Replace an existing parameter tuple with a new one. The old parameter tuple is removed and the new one is added in its place. |
| representativeNodePath | Return the contents of the Representative Node field on the Basic tab of the Type Properties dialog. |
| save | Save the definition into an otl file. |
| sections | Return a dictionary mapping section names to hou.HDASection objects. See hou.HDASection for more information on sections. |
| setComment | Set the user-defined comment. See hou.HDADefinition.comment for more information. |
| setDescription | Set the description for this definition’s node type. Houdini uses this description for user interface elements such as the TAB menu. This description is also called the operator label in Houdini. |
| setExtraFileOption | Set an entry in the dictionary of extra file options. See hou.HDADefinition.extraFileOptions for more information. value may be an integer, float, string, or sequence of 2, 3, or 4 numbers. |
| setExtraInfo | Set extra information about the asset definition that isn’t stored elsewhere, like the representative node, guide geometry, etc. This string is encoded in a specific format, so it is recommended that you only call this method with values returned from hou.HDADefinition.extraInfo. |
| setIcon | Set the icon for this definition’s node type. See hou.HDADefinition.icon for more information. |
| setIsPreferred | Set whether this definition is preferred. See hou.HDADefinition.isPreferred for more information. |
| setMaxNumInputs | Set the maximum number of inputs that node instances of this digital asset may have. This number must be greater than or equal to the minimum number of inputs. If it is 5 or greater, Houdini will use a merge SOP-style input connector that allows an unlimited number of inputs. Otherwise, the node will have between 0 and 4 input connectors, each of which may or may not be connected, that correspond to the subnet indirect inputs inside the digital asset. |
| setMinNumInputs | Set the minimum number of connected inputs that node instances of this digital asset must have. min_num_inputs must be between 0 and 4, inclusive. If a node does not have the minimum number of inputs, it will generate an error. |
| setModificationTime | Set the modification time for the definition to the given POSIX timestamp. If the time parameter is negative, uses the current time. |
| setOptions | Set this digital asset definition’s options to the data in a hou.HDAOptions object. See hou.HDAOptions for more information. |
| setParmTemplateGroup | Change the parameters for this digital asset. |
| setVersion | Set the user-defined version string. See hou.HDADefinition.version for more information. |
| updateFromNode | Update and save the definition to match the contents of a given unlocked instance of the asset. Calling this method is the same as selecting Save Operator Type on the node’s menu. |
| version | Return the user-defined version string. By default, the version is an empty string. It is up to you how you use this version information; it is passed to the Sync Node Version event handler script for performing parameter upgrades. |
nodeType(self)→ hou.NodeTypeReturn the node type defined by this digital asset. Raises hou.OperationFailed if the digital asset is not installed.
nodeTypeCategory(self)→ hou.NodeTypeCategoryReturn the node type category (e.g. Objects, SOPs, DOPs, etc.) for the node type defined by this digital asset. See hou.NodeTypeCategory for more information.
It is safe to call this method if the digital asset is not installed. If the digital asset is installed, this method is equivalent to
self.nodeType().category().nodeTypeName(self)→strReturn the name of the node type defined by this digital asset. Raises hou.OperationFailed if the digital asset is not installed.
If the digital asset is installed, this method is a shortcut for
self.nodeType().name().libraryFilePath(self)→strReturn the path to the otl file containing the digital asset’s definition.
Note that it is possible to save an asset with a hip file, without storing it in an otl file. In this case, this method returns
"Embedded".isInstalled(self)→boolReturn whether this definition is installed in Houdini.
It is possible to access HDADefinition objects in otl files that are not installed with hou.hda.definitionsInFile.
See also hou.hda.installFile.
updateFromNode(self, node)Update and save the definition to match the contents of a given unlocked instance of the asset. Calling this method is the same as selecting Save Operator Type on the node’s menu.
def saveUnlockedNodes(): '''Look through all the nodes in the file for unlocked digital asset instances and save and lock them.''' for node in hou.node("/").allSubChildren(): if node.type().definition() is None or node.isLocked(): continue node.type().definition().updateFromNode(node) node.matchCurrentDefinition()
save(self, file_name, template_node=None, options=None)Save the definition into an otl file.
file_name Where to save the definition. To save to the current otl file, use the return value from hou.HDADefinition.libraryFilePath.
template_node Either
Noneor a hou.Node object containing an unlocked instance of the digital asset that defines the definition’s new contents. IfNone, this method does not update the definition’s contents.options Either
Noneor a hou.HDAOptions object that specifies extra behaviors of the definition. If template_node is notNone, the compressContents, lockContents, saveSpareParms, and makeInitialParmsDefaults values of the hou.HDAOptions object are used. Otherwise, only the compressContents value is used.See also hou.HDADefinition.updateFromNode for a way to save an unlocked node’s definition to the current otl file. See also hou.HDADefinition.copyToHDAFile.
copyToHDAFile(self, file_name, new_name=None, new_menu_name=None)Copy this definition into an otl file.
file_name The otl file where the definition will be saved. If the file does not already exist, it will be created. If it already contains a definition for this node type, it will be overwritten.
new_name The new name of the node type. If None, the definition will be saved as the existing node type name. See also hou.NodeType.name.
new_menu_name The new description of the node type that appears in the tab menu. If None, Houdini will use the existing description. Note that the node type name must be unique within the otl file, so saving the definition with a new description to an otl file containing a definition with the old node name will still overwrite the existing definition. See also hou.NodeType.description.
isCurrent(self)→boolReturn whether this definition is the one currently in use by Houdini.
This example shows how you can access other definitions for the same node type:
def otherDefinitions(definition): '''Given an HDADefinition object, return the other loaded definitions for the same node type.''' # Look through all the loaded otl files for definitions providing # the same node type. result = [] for otl_file in hou.hda.loadedFiles(): # Skip the otl file containing the definition that was passed in. if otl_file == definition.libraryFilePath(): continue for other_definition in hou.hda.definitionsInFile(otl_file): if other_definition.nodeType() == definition.nodeType(): result.append(other_definition) return result
# Print the paths to otl files providing other definitions for a digital asset instance. >>> for other_definition in otherDefinitions(hou.node("/obj/my_hda1").type().definition()): ... print other_definition.libraryFilePath() /path/to/file1.otl /path/to/file2.otl
isPreferred(self)→boolReturn whether this definition is preferred.
After loading otl files, Houdini uses a set of rules to resolve conflicts when it encounters multiple definitions for the same node type (e.g. preferring the most recent otl file, preferring definitions embedded in the hip file, etc.). When these rules do not use the definition you want, you can override them by explicitly marking a definition as preferred. Houdini saves this list of preferred definitions with the hip file. Marking a definition as not preferred will remove it from this list, and the normal rules will apply again.
setIsPreferred(self, preferred)Set whether this definition is preferred. See hou.HDADefinition.isPreferred for more information.
destroy(self)Uninstall this definition and delete it from the otl file. Any node instances of this asset will warn that they are using an incomplete asset definition.
See also hou.hda.uninstallFile.
sections(self)→dictofstrto hou.HDASectionReturn a dictionary mapping section names to hou.HDASection objects. See hou.HDASection for more information on sections.
addSection(self, name, contents="")→ hou.HDASectionCreate a new section with the specified contents. If a section already exists with this name, changes the existing contents to the new contents. Note that the contents may contain binary data. Also note that section names may contain '/'.
See hou.HDASection for more information on sections. To remove a section, use hou.HDASection.destroy.
def addSectionFromFile(hda_definition, section_name, file_name): '''Add a section whose contents come from a file. If the section already exists, replace its contents.''' section_file = open(file_name, "r") hda_definition.addSection(section_name, section_file.read()) section_file.close()
removeSection(self, name)Remove an existing section. Only remove sections that you explicitly added. Do not remove the special sections that Houdini uses to store the contents of the digital asset definition, or Houdini will generate errors or strange side effects.
See hou.HDASection for more information on sections. Note that hou.HDASection.destroy will also remove a section.
Raises hou.OperationFailed if no such section exists in the definition.
minNumInputs(self)→intReturn the minimum number of connected inputs that node instances of this digital asset can have. If these inputs are not connected, the node will generate an error.
See also hou.NodeType.minNumInputs.
setMinNumInputs(self, min_num_inputs)Set the minimum number of connected inputs that node instances of this digital asset must have.
min_num_inputsmust be between 0 and 4, inclusive. If a node does not have the minimum number of inputs, it will generate an error.maxNumInputs(self)→intReturn the maximum number of inputs that node instances of this digital asset can have. Return a number greater than 4 if this node type can accept an unlimited number of inputs.
See also hou.NodeType.maxNumInputs.
setMaxNumInputs(self, max_num_inputs)Set the maximum number of inputs that node instances of this digital asset may have. This number must be greater than or equal to the minimum number of inputs. If it is 5 or greater, Houdini will use a merge SOP-style input connector that allows an unlimited number of inputs. Otherwise, the node will have between 0 and 4 input connectors, each of which may or may not be connected, that correspond to the subnet indirect inputs inside the digital asset.
See hou.Node.inputConnectors and hou.SubnetIndirectInput for more information on input connectors and subnet indirect inputs.
version(self)→strReturn the user-defined version string. By default, the version is an empty string. It is up to you how you use this version information; it is passed to the Sync Node Version event handler script for performing parameter upgrades.
setVersion(self, version)Set the user-defined version string. See hou.HDADefinition.version for more information.
comment(self)→strReturn the user-defined comment string. It is up to you how you use the comment; it is not used by Houdini.
setComment(self, comment)Set the user-defined comment. See hou.HDADefinition.comment for more information.
description(self)→strReturn the description for this definition’s node type. Houdini uses this description for user interface elements such as the TAB menu. This description is also called the operator label in Houdini.
See also hou.NodeType.description.
setDescription(self, description)Set the description for this definition’s node type. Houdini uses this description for user interface elements such as the TAB menu. This description is also called the operator label in Houdini.
See also hou.HDADefinition.description and hou.NodeType.description.
icon(self)→strReturn the name or path of the icon for this definition’s node type. Note that Houdini uses its search path to locate icons, so you do not need to pass in a full path.
See also hou.NodeType.icon.
setIcon(self, icon)Set the icon for this definition’s node type. See hou.HDADefinition.icon for more information.
modificationTime(self)→ intReturn the time when the definition was last modified. This time is returned as a POSIX timestamp, such as is returned by
time.time().>>> import time >>> time.ctime(hou.nodeType(hou.objNodeTypeCategory(), "toon_character"). ... definition().modificationTime()) 'Thu Nov 6 18:22:38 2008'
setModificationTime(self, time=-1)Set the modification time for the definition to the given POSIX timestamp. If the time parameter is negative, uses the current time.
See also hou.HDADefinition.modificationTime.
embeddedHelp(self)→strReturn the help text embedded in the digital asset. Return an empty string if no embedded help exists.
Embedded help typically comes from the Help tab of the operator type properties window, but it may also come from a dialog script.
options(self)→ hou.HDAOptionsReturn a hou.HDAOptions object for the options stored in this digital asset. See hou.HDAOptions for more information.
setOptions(self, options)Set this digital asset definition’s options to the data in a hou.HDAOptions object. See hou.HDAOptions for more information.
extraFileOptions(self)→dictofstrtobool,int,float,strReturn a dictionary containing the extra options attached to sections in the asset’s definition. For example, event handler scripts such as OnCreated are stored as sections inside the asset, and extra metadata in this dictionary determines whether Houdini runs these scripts as Python as as Hscript.
These is one dictionary for the entire asset, and keys in this dictionary are usually of the form section_name/option_name. For example, if the OnCreated section is marked as containing Python code, this dictionary will contain “OnCreated/IsPython” set to True.
Note that the contents of this dictionary are saved in the ExtraFileOptions section and are encoded in a binary format.
See also hou.HDADefinition.setExtraFileOption and hou.HDADefinition.removeExtraFileOption.
setExtraFileOption(self, name, value)Set an entry in the dictionary of extra file options. See hou.HDADefinition.extraFileOptions for more information.
valuemay be an integer, float, string, or sequence of 2, 3, or 4 numbers.The following example function marks an section, such as OnCreated, as containing Python code:
def markSectionAsPython(definition, section_name): definition.setExtraFileOption(section_name + "/IsPython", True)
removeExtraFileOption(self, name)Remove an entry in the dictionary of extra file options. See hou.HDADefinition.extraFileOptions for more information.
valuemay be a bool, integer, float, string, or sequence of 2, 3, or 4 numbers.Raises hou.OperationFailed if there is no entry in the dictionary with this name.
extraInfo(self)→strReturn a string storing extra information about the asset definition that isn’t stored elsewhere, like the representative node, guide geometry, whether default parameters are hidden, etc.
See also hou.HDADefinition.representativeNodePath and hou.HDADefinition.hideDefaultParameters to more easily retrieve some portions of the extra info.
setExtraInfo(self, extra_info)Set extra information about the asset definition that isn’t stored elsewhere, like the representative node, guide geometry, etc. This string is encoded in a specific format, so it is recommended that you only call this method with values returned from hou.HDADefinition.extraInfo.
representativeNodePath(self)→strReturn the contents of the Representative Node field on the Basic tab of the Type Properties dialog.
For object-level digital assets that contain other object nodes, it is possible to make Houdini treat your digital asset like a camera or light by choosing a node inside the asset to represent it. For example, if you choose a camera inside the asset as the representative node, instances of the digital asset will appear in the viewport’s list of camera objects.
Note that this value is also stored in the string returned by hou.HDADefinition.extraInfo.
hideDefaultParameters(self)→boolReturn whether the parameters that are common to nodes types in this node type category are hidden or not. For example, nearly all objects have common translation, rotation, scale, etc. parameters, and object level digital assets have these parameters by default. If hidden, though, these parameters are still there but are not displayed to the user.
Note that this value is also stored in the string returned by hou.HDADefinition.extraInfo.
parmTemplateGroup(self)→ hou.ParmTemplateGroupReturn the group of parm templates corresponding to this asset definition’s parameter interface.
You can edit the parameter layout for this asset by getting the current parameter group, modifying it, and calling setParmTemplateGroup with it.
See hou.ParmTemplateGroup for more information.
setParmTemplateGroup(self, parm_template_group, rename_conflicting_parms=False)Change the parameters for this digital asset.
parm_template_groupA hou.ParmTemplateGroup object containing the new parameter layout.
rename_conflicting_parmsIf
True, parameters in the group with the same parm tuple names will be automatically renamed. IfFalseand there are parms with the same name, this method raises hou.OperationFailed.This method is preferred over the other parameter-related methods in this class (addParmTuple, removeParmTuple, replaceParmTuple, addParmFolder, removeParmFolder) because it lets you more easily make manipulate parameters. It is also faster when making many parameter changes because the other methods resave the otl file after each change.
See hou.Node.setParmTemplateGroup to change the parameter interface of an individual node.
addParmFolder(self, folder_name, in_folder=(), parm_name=None, create_missing_folders=False)Adds a folder to this node type’s parameters.
folder_name The name of the folder that is displayed in the parameter dialog.
in_folder A sequence of folder name strings to indicate where the folder should go. If this sequence is empty, the folder will go in top level set of folders. It it is, for example,
("Transform",), the folder is added inside the Transform folder. If it is("Transform", "Options"), it will go inside the Options folder inside the Transform folder.parm_name The name of the underlying parameter tuple corresponding to the set of folders. For example, the folders in a set might be named Transform, Subnet, and Controls, and these correspond to one parameter tuple named, say,
'stdswitcher0'. The value of the parameter in this tuple is the index of the folder that is open.If this is the first folder to go in the set,
parm_nameis used as the parameter name. Otherwise, it is ignored and Houdini uses the parameter name of the first folder in the set.If this is the first folder in the set and parm_name is None, it will default to
'folder0'. If parm_name is already in use, Houdini automatically generates a unique name.create_missing_folders Whether Houdini should create folders specified in
in_folderthat do not already exist. If this parameter is True, you can use this method to add nested folders in one call.Note that you can add folders by passing a hou.FolderParmTemplate to the
addSpareParmTuplemethod, so this method is deprecated. Note also thataddSpareParmTupleis deprecated in favor ofsetParmTemplateGroup.See also the
removeParmFolderandaddParmTuplemethods.This method is deprecated in favor of
setParmTemplateGroup.removeParmFolder(self, folder)Remove an empty folder from this node type’s parameters.
folder A sequence of folder names. For example, to remove the Output folder, pass in
("Output",)and not"Output".Raises hou.OperationFailed if the folder does not exist or it is not empty. Use hou.HDADefinition.removeParmTuple to remove all the parameters inside the folder before calling this method.
See also
addParmFolder, hou.ParmTemplateGroup.remove, and hou.ParmTemplateGroup.findFolder.This method is deprecated in favor of hou.HDADefinition.setParmTemplateGroup.
addParmTuple(self, parm_template, in_folder=(), create_missing_folders=False)Add a parameter tuple to this node type’s parameters. Houdini places the new parameter at the bottom of the parameters in a particular folder.
parm_template An instance of a hou.ParmTemplate subclass that describes the parameter.
in_folder A sequence of folder name strings to tell Houdini which folder to put the parameter in. If this sequence is empty, the parameter will go in top level set of folders. It it is, for example,
("Transform",), the parameter is added inside the Transform folder. If it is("Transform", "Options"), it will go inside the Options folder inside the Transform folder.create_missing_folders Whether Houdini should create folders specified in
in_folderthat do not already exist. If this parameter is True, you can create folders without having to call hou.HDADefinition.addParmFolder.Note that this method can add a single folder by passing a hou.FolderParmTemplate for
parm_template.See also hou.HDADefinition.replaceParmTuple.
This method is deprecated in favor of hou.HDADefinition.setParmTemplateGroup.
removeParmTuple(self, name)Remove a parameter tuple from this node type’s parameters.
See also hou.HDADefinition.addParmTuple and hou.HDADefinition.removeParmFolder.
This method is deprecated in favor of hou.HDADefinition.setParmTemplateGroup.
replaceParmTuple(self, parm_tuple_name, parm_template)Replace an existing parameter tuple with a new one. The old parameter tuple is removed and the new one is added in its place.
parm_tuple_name The name of the parameter tuple to replace. Raises hou.OperationFailed if no parameter tuple exists with this name.
parm_template A hou.ParmTemplate describing the new parameter tuple.
The new parameter tuple may or may not have the same name as the old one. By providing a parameter tuple with the same name, you can modify an existing parameter tuple. The following example function changes the definition of the asset to make a parameter tuple visible or invisible in all nodes of that type.
To show or hide a parameter in just one instance of a node, use hou.ParmTuple.hide.
To change a spare parameter on a node, use hou.Node.replaceSpareParmTuple or hou.Node.setParmTemplateGroup.
This method is deprecated in favor of hou.HDADefinition.setParmTemplateGroup.