A digital asset definition defines a node type and exists inside an hda 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 hda file contains one or more digital asset definitions, and installing an hda 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
Type
nodeType()
→ hou.NodeType
Return the node type defined by this digital asset. Raises hou.OperationFailed if the digital asset is not installed.
nodeTypeCategory()
→ hou.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.
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()
→ str
Return 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()
.
Library file
libraryFilePath()
→ str
Return the path to the hda 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 hda file. In this case, this method returns "Embedded"
.
isInstalled()
→ bool
Return whether this definition is installed in Houdini.
It is possible to access HDADefinition objects in hda files that are not installed with hou.hda.definitionsInFile().
See also hou.hda.installFile().
Updating and saving
updateFromNode(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.matchesCurrentDefinition(): continue node.type().definition().updateFromNode(node) node.matchCurrentDefinition()
save(file_name, template_node=None, options=None, create_backup=True)
Save the definition into an hda file.
file_name
Where to save the definition. To save to the current hda file, use the return value from hou.HDADefinition.libraryFilePath().
template_node
Either None
or a hou.Node object containing an unlocked instance
of the digital asset that defines the definition’s new contents.
If None
, this method does not update the definition’s contents.
options
Either None
or a hou.HDAOptions object that specifies extra
behaviors of the definition. If template_node is not None
, the
compressContents, lockContents, saveSpareParms, and
makeInitialParmsDefaults values of the hou.HDAOptions object
are used. Otherwise, only the compressContents value is used.
create_backup
Create a backup before modifying existing hda files.
See also hou.HDADefinition.updateFromNode() for a way to save an unlocked node’s definition to the current hda file. See also hou.HDADefinition.copyToHDAFile().
copyToHDAFile(file_name, new_name=None, new_menu_name=None)
Copy this definition into an hda file.
file_name
The hda 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 hda file, so saving the definition with a new description to an hda file containing a definition with the old node name will still overwrite the existing definition. See also hou.NodeType.description().
Metadata
version()
→ str
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.
setVersion(version)
Set the user-defined version string. See hou.HDADefinition.version() for more information.
comment()
→ str
Return the user-defined comment string. It is up to you how you use the comment; it is not used by Houdini.
setComment(comment)
Set the user-defined comment. See hou.HDADefinition.comment() for more information.
description()
→ str
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.
See also hou.NodeType.description().
setDescription(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()
→ str
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.
See also hou.NodeType.icon().
setIcon(icon)
Set the icon for this definition’s node type. See hou.HDADefinition.icon() for more information.
modificationTime()
→ int
Return 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(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().
isCurrent()
→ bool
Return 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 hda files for definitions providing # the same node type. result = [] for hda_file in hou.hda.loadedFiles(): # Skip the hda file containing the definition that was passed in. if hda_file == definition.libraryFilePath(): continue for other_definition in hou.hda.definitionsInFile(hda_file): if other_definition.nodeType() == definition.nodeType(): result.append(other_definition) return result
# Print the paths to hda 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.hda /path/to/file2.hda
isPreferred()
→ bool
Return whether this definition is preferred.
After loading hda 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 hda 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(preferred)
Set whether this definition is preferred. See hou.HDADefinition.isPreferred() for more information.
embeddedHelp()
→ str
Return 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.
userInfo()
→ str
Return a string containing user specified information about the asset definition.
setUserInfo(extra_info)
Set user information about the asset definition. This info isn’t used by Houdini so it can contain any text.
options()
→ hou.HDAOptions
Return a hou.HDAOptions object for the options stored in this digital asset. See hou.HDAOptions for more information.
setOptions(options)
Set this digital asset definition’s options to the data in a hou.HDAOptions object. See hou.HDAOptions for more information.
extraInfo()
→ str
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.
See also hou.HDADefinition.representativeNodePath() and hou.HDADefinition.hideDefaultParameters() to more easily retrieve some portions of the extra info.
setExtraInfo(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()
→ str
Return 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().
Deletion
destroy()
Uninstall this definition and delete it from the hda file. Any node instances of this asset will warn that they are using an incomplete asset definition.
See also hou.hda.uninstallFile().
Embedded files
sections()
→ dict
of str
to hou.HDASection
Return a dictionary mapping section names to hou.HDASection objects. See hou.HDASection for more information on sections.
hasSection(name)
→ bool
Return True if the HDA definition contains a section with the specified name and False otherwise.
See hou.HDASection for more information on sections.
addSection(name, contents="", compression_type=hou.compressionType.NoCompression)
→ hou.HDASection
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 '/'.
You can optionally specify a compression type, hou.compressionType, to compress the contents. Note that you must specify the same compression type when reading the contents back to decompress them.
See hou.HDASection for more information on sections. To remove a section, use hou.HDASection.destroy().
Sections can have associated properties stored in the hou.HDADefinition.extraFileOptions().
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(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.
extraFileOptions()
→ dict
of str
to bool
, int
, float
, str
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.
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(name, value, type_hint = hou.fieldType::NoSuchField)
Set an entry in the dictionary of extra file options. See hou.HDADefinition.extraFileOptions() for more information.
name
The name of the option to set.
value
An integer, float, string, hou.Vector2, hou.Vector3, hou.Vector4, hou.Quaternion, hou.Matrix3, hou.matrix4, or sequence of numbers.
type_hint
Used to determine the exact hou.fieldType desired when the specified value type is not enough to unambiguously determine it.
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(name)
Remove an entry in the dictionary of extra file options. See hou.HDADefinition.extraFileOptions() for more information.
Raises hou.OperationFailed if there is no entry in the dictionary with this name.
uncompressedContents()
→ str
Return a string containing the data of the uncompressed Contents
section.
The Contents
section consists of data in the CPIO format representing the
child nodes used to create a node instance of the HDA.
See also hou.HDADefinition.parsedContents().
parsedContents()
→ tuple
of (str, str)
Return a list of (name, value) pairs of the parsed from the Contents
section.
The Contents
section consists of the child nodes used to create a node
instance of the HDA.
See also hou.HDADefinition.uncompressedContents().
Inputs and outputs
minNumInputs()
→ int
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.
See also hou.NodeType.minNumInputs().
setMinNumInputs(min_num_inputs)
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.
maxNumInputs()
→ int
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.
See also hou.NodeType.maxNumInputs().
setMaxNumInputs(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.
Parameters
hideDefaultParameters()
→ bool
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.
Note that this value is also stored in the string returned by hou.HDADefinition.extraInfo().
parmTemplateGroup()
→ hou.ParmTemplateGroup
Return 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(parm_template_group, rename_conflicting_parms=False, create_backup=True)
Change the parameters for this digital asset.
parm_template_group
:
A hou.ParmTemplateGroup object containing the new parameter
layout.
rename_conflicting_parms
If True
, parameters in the group with the same parm tuple names will
be automatically renamed. If False
and there are parms with the same
name, this method raises hou.OperationFailed.
create_backup
Create a backup before saving the definition the its hda file.
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 hda file after each change.
See hou.Node.setParmTemplateGroup() to change the parameter interface of an individual node.
addParmFolder(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_name
is 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_folder
that
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 addSpareParmTuple
method, so this method is deprecated. Note
also that addSpareParmTuple
is deprecated in favor of
setParmTemplateGroup
.
See also the removeParmFolder
and addParmTuple
methods.
This method is deprecated in favor of setParmTemplateGroup
.
removeParmFolder(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(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_folder
that
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(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(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().
Misc
compileCodeSection(source_section, destination_section)
This function is deprecated. Compiled VEX code should no longer be stored inside of an HDA.