Inheritence |
|
Unlike all other hou.ParmTemplate subclasses, a folder does not correspond to an individual hou.ParmTuple. Instead, the set of adjacent folders form a folder set, and there is one parameter for this set that controls which folder is currently visible. These folder sets correspond to hou.FolderSetParmTemplate objects.
Folder parm template objects are useful when manipulating the parameter interface of a node or a digital asset definition. Unlike folder set parm templates, they contain the parm templates inside the folder. They also let you add, remove, or hide an individual folder or move it from set one to another using hou.ParmTemplateGroup objects. Doing these individual folder-level operations is not possible with folder set parm templates.
Note that folder parm templates are also used to represent multiparm blocks, much like the Type Properties dialog does. The folder parm template’s hou.folderType determines whether it is a folder or a multiparm block. Unlike folder parm templates, which do not correspond directly to parameter instances, a multiparm parm template does correspond to an integer parameter that controls the number of instances of the multiparm.
Methods
__init__(name, label, parm_templates=(), folder_type=hou.folderType.Tabs, is_hidden=False, ends_tab_group=False, tags={})
Create a new folder parm template.
name
The internal name of the parm template. Normally, parm template names correspond directly to parm tuples on nodes. However, because folder sets, not folders, correspond directly to parm tuples, the name used for the folder set parm tuple is the name of the first folder parm template in the set of adjacent folder parm templates.
label
The name of the folder that is displayed in the parameter dialog.
parm_templates
A sequence of hou.ParmTemplate subclass objects for the parameters inside the folder. Folders may be nested in other folders by putting FolderParmTemplates in this sequence.
folder_type
A hou.folderType enumerated value controlling whether the parameter is a folder or a multiparm block. This value controls the look of the folder/multiparm instance.
is_hidden
Whether or not this folder is hidden.
ends_tab_group
If True
, this folder will be the last in the folder set, even if
the next parameter is also a folder. In that case, the next parameter
will begin a new folder set.
tags
A dictionary of extra information attached to the parm template.
parmTemplates()
→ tuple of hou.ParmTemplate
Return a tuple of copies of the parm templates stored inside this folder.
Because copies are returned, you cannot change the contents of the parm templates inside this folder by modifying the parm templates returned. Instead, use methods in hou.ParmTemplateGroup to modify parm templates in this folder.
addParmTemplate(parm_template)
Append a parm template to the end of the list of parm templates inside the folder.
Note that hou.ParmTemplateGroup provides a number of methods to insert parm templates inside folders, including hou.ParmTemplateGroup.appendToFolder().
setParmTemplates(parm_templates)
Replace the parm templates inside this folder with a new sequence of parm templates.
folderType()
→ hou.folderType enum value
Return the type of folder. Note that the folder may actually be a multiparm block.
setFolderType(folder_type)
Set the type of folder to a hou.folderType enum value.
isActualFolder()
→ bool
Return whether or not this parm template corresponds to an actual folder, as opposed to a multiparm or import block.
This method can be implemented as follows:
def isActualFolder(self): return self.folderType() in ( hou.folderType.Tabs, hou.folderType.RadioButtons)
defaultValue()
→ int
Return the integer default value.
The default value is only used for folders that are multiparm blocks, and controls the default number of multiparm instances in newly created nodes.
setDefaultValue(default_value)
Set the default value to an integer.
The default value is only used for folders that are multiparm blocks. See the defaultValue method for more information.
endsTabGroup()
→ bool
Return whether this folder will be the last in the folder set, even if the next parameter is also a folder. In that case, the next parameter will begin a new folder set.
This parameter only has meaning if the parm template is for an actual folder and not for a multiparm block.
Methods from hou.ParmTemplate
clone()
→ hou.ParmTemplate
Return a copy of this parm template.
This method can be called on an instance of a ParmTemplate subclass and an instance of the subclass is properly returned.
name()
→ string
Return the internal name of the parm template. This is the name that hou.ParmTuple objects created from this parm template will have.
Note that the names of hou.Parm objects inside ParmTuples based off this ParmTemplate are determined by this name, the number of components in this parm template, and the naming scheme. See the namingScheme method for more information.
setName(name)
Change the internal name of this parm template. Remember that ParmTemplates just store data, so the name change will not have any effect unless this parm template is later used to modify a parameter layout in Houdini.
label()
→ string
Return the name of the parameter tuple that is displayed in the parameter pane.
setLabel(label)
Change the name of the label that is displayed in the parameter pane.
type()
→ hou.parmTemplateType enum value
Return the enumerated value identifying the type of this parameter.
Remember that ParmTemplate objects are always instances of a subclass of this class. The following table shows the mapping between hou.parmTemplateType enumeration values and ParmTemplate subclasses:
Enumerated Value
ParmTemplate Subclass
dataType()
→ hou.parmData enum value
Return the data type stored in hou.Parm instances inside hou.ParmTuple instances corresponding to this ParmTemplate.
For example, suppose this parm tuple is a hou.FloatParmTemplate with 3 components. The corresponding hou.ParmTuple will have 3 hou.Parm objects inside it, and each will store a floating point value. In this example, this method would return hou.parmData.Float.
numComponents()
→ int
Return the number of values stored inside hou.ParmTuple instances of this ParmTemplate.
For example, if this parm template has 3 components, there will be 3 parameter fields displayed in the parameter pane and there will be 3 hou.Parm objects inside a hou.ParmTuple based off this parm template.
setNumComponents(num_components)
→ int
Set the number of values stored inside hou.ParmTuple instances of this ParmTemplate.
Note that some ParmTemplate subclasses only support one component, so calling this method with a value other than 1 may raise a hou.OperationFailed exception. Also, changing the number of components may automatically change the size of the tuple of default values for some ParmTemplate subclasses.
namingScheme()
→ hou.parmNamingScheme enum value
Return the naming scheme used to name parameters inside the parm tuple for this ParmTemplate.
For example, if the naming scheme is
hou.parmNamingScheme.XYZW and the parm template
is named "foo"
and has 3 components, the parameters will be named
"foox"
, "fooy"
, and "fooz"
. On the other hand, if the naming scheme
was hou.parmNamingScheme.Base1, the parameters
would be named "foo1"
, "foo2"
, and "foo3"
.
Note that when the parm template only has 1 component, the parm name is the same as the parm tuple name.
See hou.parmNamingScheme for more information.
setNamingScheme(naming_scheme)
Set the naming scheme used to name parameters inside the parm tuple for this ParmTemplate to a hou.parmNamingScheme enum value.
See the namingScheme
method for more information.
look()
→ hou.parmLook enum value
Return the look of this parameter in the parameter pane. For example, a tuple of 3 floats can be displayed as a 3D vector or as an RGB color.
See hou.parmLook for more information.
setLook(look)
Set the look of this parameter to a hou.parmLook enum value.
See the look
method for more information.
help()
→ str
Return the help that Houdini displays when you hover over the parameter label in the parameter pane.
setHelp(help)
Set the help that Houdini displays when you hover over the parameter label in the parameter pane.
isHidden()
→ bool
Return whether this parameter is hidden in the parameter pane.
hide(on)
Marks this parameter as visible or invisible in the parameter pane.
Note that hidden parameters still exist, and can be evaluated, channel-referenced, etc. They simply will not be displayed in the parameter pane.
isLabelHidden()
→ bool
Return whether the label for this parameter is hidden in the parameter pane.
hideLabel(on)
Hide or show the label for this parameter in the parameter pane.
joinsWithNext()
→ bool
Return whether this parameter is displayed on the same line as the next parameter in the parameter pane.
joinWithNext()
→ bool
This method is deprecated in favor of the joinsWithNext method.
setJoinWithNext(on)
Sets whether this parameter is displayed on the same line as the next parameter in the parameter pane.
disableWhen()
→ str
This method is deprecated in favor of the conditionals method.
setDisableWhen(disable_when)
This method is deprecated in favor of the setConditional method.
conditionals()
→ dict of [Hom:hou.parmCondType] enum value to string
Returns the set of conditionals currently affecting this parameter.
See the Conditionals section of the Operator Type Properties window help for more information on this string.
setConditional(type, conditional)
Set a conditional string of the given hou.parmCondType type for this parameter. This string consists of rules on how this parameter’s display behaves when other parameters change.
See the Conditionals section of the Operator Type Properties window help for more information on this string.
tags() -> dict of string to string
Return a dictionary of extra data stored in the parm template.
Houdini uses this dictionary to attach arbitrary data to parm templates. The keys in this dictionary vary depending on the ParmTemplate type and its use.
scriptCallback()
→ str
Return the contents of the script that Houdini runs when this parameter changes. This script is most commonly used in hou.ButtonParmTemplate objects to respond to the button being pressed.
Note that Houdini uses the tags dictionary to store the script callback information.
setScriptCallback(script_callback)
Set the callback script to the given string. This script runs in response to a parameter change.
See the scriptCallback method for more information.
scriptCallbackLanguage()
→ hou.scriptLanguage enum value
Return the language of the script that Houdini runs when this parameter changes.
Note that Houdini uses the tags dictionary to store the script callback information.
See also the scriptCallback method.
setScriptCallbackLanguage(script_callback_language)
Set the script callback language to a hou.scriptLanguage enum value.
See the scriptCallbackLanguage method for more information.
setTags(tags)
Set the dictionary of extra data stored in this parm template.
See the tags method for more information.
asCode(function_name=None, variable_name=None)
→ str
Return a string containing Python statements that can be executed to
recreate the parameter template. To run the string, use Python’s
compile
, or execfile
functions or the exec
statement.
function_name
If function_name is specified, then the code returned creates a Python function with the given name. function_name must be a non-zero length string consisting of only alphanumeric and underscore characters. Any invalid characters are internally converted to underscores.
The function returns a reference to the newly created parameter template object.
variable_name
The name of a Python variable that the result code will assign to.
If None
, Houdini uses the variable name "hou_parm_template"
.
Here is an example of saving the output to a file and then loading it back into Houdini:
# Get a reference to the target parameter template. node = hou.node("/obj/geo1") parm_template = node.parm("tx").parmTemplate() # Execute asCode and write the output script to a file. code = parm_template.asCode() source_file = open("create_parm_template.py", "w") source_file.write(code) source_file.close() # Execute the script. The new parameter template will be stored # in the 'hou_parm_template' variable. execfile("create_parm_template.py") # Add a spare parameter to the node using the saved parameter # template. node.addSpareParmTuple(hou_parm_template)
Here is an example of saving the output into a function in a file and then calling it from Houdini:
# Get a reference to the target parameter template. node = hou.node("/obj/geo1") parm_template = node.parm("tx").parmTemplate() # Execute asCode and write the function definition to a file. code = parm_template.asCode(function_name="createParmTemplate") source_file = open("parmtemplatelib.py", "w") source_file.write(code) source_file.close() # Call the function definition. import parmtemplatelib hou_parm_template = parmtemplatelib.createParmTemplate() # Add a spare parameter to the node using the saved parameter # template. node.addSpareParmTuple(hou_parm_template)