Inheritence |
|
Note that integer parameters may also be menu parameters. Integer parameters with menus are conceptually the same as parameters derived from hou.MenuParmTemplate.
Methods
__init__(name, label, num_components, default_value=(), min=0, max=10, min_is_strict=False, max_is_strict=False, naming_scheme=hou.parmNamingScheme.XYZW, menu_items=(), menu_labels=(), icon_names=(), item_generator_script=None, item_generator_script_language=None, menu_type=hou.menuType.Normal, disable_when=None, is_hidden=False, is_label_hidden=False, join_with_next=False, help=None, script_callback=None, script_callback_language=hou.scriptLanguage.Hscript, tags={}, default_expression=(), default_expression_language=())
Construct a new IntParmTemplate.
name
See hou.ParmTemplate.name() for more information.
label
See hou.ParmTemplate.label() for more information.
num_components
See hou.ParmTemplate.numComponents() for more information.
default_value
See the defaultValue method for more information.
min
See the minValue method for more information.
max
See the maxValue method for more information.
min_is_strict
See the minIsStrict method for more information.
max_is_strict
See the maxIsStrict method for more information.
look
See hou.ParmTemplate.look() for more information.
naming_scheme
See hou.ParmTemplate.namingScheme() for more information.
menu_items
See the menuItems method
for more information. Note that num_components
must be 1
if
menu items are supplied.
menu_labels
See the menuLabels method for more information.
If this parameter is not given, it defaults to the value of
the menu_items
parameter.
icon_names
See the iconNames method for more information.
If this parameter is an empty tuple, the menu will not contain icons.
item_generator_script
See the
itemGeneratorScript
method for more information. Note that num_components
must be 1
if
a script is given.
item_generator_script_language
See the
itemGeneratorScriptLanguage
method for more information. If this parameter is None
it defaults
to hou.scriptLanguage.Python.
menu_type
See the menuType method for more information.
disable_when
See hou.ParmTemplate.disableWhen() for more information.
is_hidden
See hou.ParmTemplate.isHidden() for more information.
is_label_hidden
See hou.ParmTemplate.isLabelHidden() for more information.
join_with_next
See hou.ParmTemplate.joinsWithNext() for more information.
help
See hou.ParmTemplate.help() for more information.
script_callback
See hou.ParmTemplate.scriptCallback() for more information.
script_callback_language
See hou.ParmTemplate.scriptCallbackLanguage() for more information.
tags
See hou.ParmTemplate.tags() for more information.
default_expression
See the defaultExpression method for more information.
default_expression_language
See the defaultExpressionLanguage method for more information.
defaultValue()
→ tuple of int
Return the default value for new parameter instances.
For example, suppose this parm template is named "divisions", the naming scheme is XYZW, it has 3 components, and the default value is (10, 20, 30). The corresponding parm tuple instance on a node would be named "divisions" and would contain parameters "divisionsx", "divisionsy", and "divisionsz". When the node is created, "divisionsx" would be 10, "divisionsy" would be 20, and "divisionsz" would be 30.
setDefaultValue(default_value)
Set the default value for new parameter instances to a sequence of ints.
See the defaultValue
method for more information. Note that if the
number of ints in the sequence is different from the number of components
in the parm template, any extra values will be discarded and any missing
values will become zeros.
defaultExpression()
→ tuple of strings
Return the default expression for new parameter instances.
The default expression takes precendence over the default value. If a component has no default expression (i.e. an empty string), then the default value is used for new parameter instances.
Note that the default expression language is needed to interpret the meaning of the default expression.
For example, suppose this parm template is named "divisions",
the naming scheme is XYZW, it has 3 components, the default value
is (10, 20, 30), the default expression is ("$F", "hou.frame()", "")
and the default expression language is (hou.scriptLanguage.Hscript
,
hou.scriptLanguage.Python
, hou.scriptLanguage.Hscript
).
Then the corresponding parm tuple instance on a node would be named
"divisions" and would contain parameters "divisionsx", "divisionsy",
"divisionsz". When the node is created,
"divisionsx" would have a default Hscript expression of "$F",
"divisionsy" would have a default Python expression of "hou.frame()",
and "divisionsz" would have a default value of 30.
setDefaultExpression(default_expression)
Set the default expression for new parameter instances to a sequence of strings.
See the hou.IntParmTemplate.defaultExpression() method for more information. Note that if the number of strings in the sequence is different from the number of components in the parm template, any extra values will be discarded and any missing expressions will become the empty string.
defaultExpressionLanguage()
→ tuple of hou.scriptLanguage
Return the default expression language for new parameter instances.
The default expression language only applies if the default expression is set. If the default expression of a component is not set, then the expression language is set to hou.scriptLanguage.Hscript.
setDefaultExpressionLanguage(default_expression_language)
Set the default expression language for new parameter instances to a sequence of hou.scriptLanguage values.
See the defaultExpressionLanguage
method for more information.
Note that if the number of hou.scriptLanguage values in the sequence
is different from the number of components in the parm template,
any extra values will be discarded and any missing expression languages
will become hou.scriptLanguage.Hscript.
minValue()
→ int
Return the minimum value of the parameter.
See also the minIsStrict method.
setMinValue(min_value)
Set the minimum value of the parameter.
See the minValue
method for more information.
maxValue()
→ int
Return the minimum value of the parameter.
See also the minIsStrict method.
setMaxValue(max_value)
Set the maximum value of the parameter.
See the maxValue
method for more information.
minIsStrict()
→ bool
Returns whether the minimum value is strictly enforced.
If a minimum value is not strictly enforced, the slider will not let you change the value below the minimum, but you can set the value to be lower than the minimum by typing it in, changing it via hou.Parm.setValue, or using the ladder handle.
If it is strictly enforced and you try to change it below the minimum value using any mechanism, Houdini will set it to the minimum value.
See also the minValue method.
setMinIsStrict(on)
Set whether the minimum value is strictly enforced.
See the minIsStrict
method for more information.
maxIsStrict()
→ bool
Return whether the maximum value is strictly enforced.
See the minIsStrict method for more information.
setMaxIsStrict(on)
Set whether the maximum value is strictly enforced.
See the maxIsStrict
method for more information.
setMenuItems(menu_items)
Set the internal menu names to the given sequence of strings.
See the menuItems method for more information.
If the new number of menu items is less than the old number, the menu labels will be shortened and the default value will be modified if it is out of range.
iconNames()
→ tuple
of str
Return the tuple of icons corresponding to the menu items. If there are no icons, returns a tuple of empty strings.
These icons are used when this parm template uses a menu.
setIconNames(icon_names)
Set the icon names to the given sequence of strings.
itemGeneratorScript()
→ str
Return the script used to generate menu items, or an empty string if there is no such script.
This script is used when this parm template uses a menu.
Note that if the item generator script language is hou.scriptLanguage.Python, this script may be either a single-line Python expression or a multi-line body of a Python function.
setItemGeneratorScript(item_generator_script)
Set the script used to generate menu items.
See the itemGeneratorScript
method for more information.
itemGeneratorScriptLanguage()
→ hou.scriptLanguage enum value
Return the script used to generate menu items, or an empty string if there is no such script.
setItemGeneratorScriptLanguage(language)
Set the script language used to generate menu items to a hou.scriptLanguage enum value.
See the itemGeneratorScriptLanguage
method for more information.
setMenuType(menu_type)
Set the type of menu to a hou.menuType enum value.
See the menuType
method for more information.
setMenuUseToken(on)
Set whether the parameter is set to the token value instead of the index.
See also the menuUseToken
method.
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)