Methods ¶
Animation ¶
alias()
→ str
Returns the parameter’s channel alias name. Returns an empty string if no such name exists.
setAlias(alias_name)
Gives the parameter another name by which it can be referenced in channels. You can pass in an empty string to remove an existing alias name.
isAutoscoped()
→ bool
Returns whether this parameter’s autoscope property is on.
isAutoSelected()
→ bool
Returns whether this parameter’s autoselect property is on.
deleteAllKeyframes()
Removes all keyframes from this parameter.
This has no effect if there are no keyframes to delete. The value of the parameter after all keyframes are removed will be the one it evaluated to at the current frame.
This function will raise a hou.ObjectWasDeleted exception if it is invoked on a parameter that does not exist in Houdini.
This function will raise a hou.PermissionError exception if writing to the specified parameter is impossible.
See also hou.Parm.deleteKeyframeAtFrame and hou.ParmTuple.deleteAllKeyframes.
deleteKeyframeAtFrame(frame)
Removes a keyframe from this parameter at the given frame.
This function will raise a hou.ObjectWasDeleted exception if it is invoked on a parameter that does not exist in Houdini.
This function will raise a hou.PermissionError exception if writing to the specified parameter is impossible.
This function will raise a hou.OperationFailed exception the parameter doesn’t have a keyframe at the given frame.
See also hou.Parm.deleteAllKeyframes.
keyframes()
→ tuple of hou.BaseKeyframe
Returns the keyframes on this parameter.
keyframesAfter(frame)
→ tuple of hou.BaseKeyframe
Returns a tuple of keyframes on this parameter that occur at or after
frame
. If no keyframes are found an empty tuple is returned.
keyframesBefore(frame)
→ tuple of hou.BaseKeyframe
Returns a tuple of keyframes on this parameter that occur at or before
frame
. If no keyframes are found an empty tuple is returned.
keyframeExtrapolation(before)
→ hou.parmExtrapolate
Returns extrapolation on this parameter for time before the first keyframe or after the last keyframe. Extrapolation defines how a parm value is evaluated outside the keyframe range.
before
If set to true, returns extrapolation for evaluations before the first keyframe. If set to false, returns extrapolation for evaluations after the last keyframe.
This function will raise a hou.ObjectWasDeleted exception if it is invoked on a parameter that does not exist in Houdini.
This function will raise a hou.OperationFailed exception the parameter doesn’t have a valid animation channel.
keyframesInRange(start_frame, end_frame)
→ tuple of hou.BaseKeyframe
Returns a tuple of keyframes on this parameter that fall in the range
start_frame
to end_frame
, inclusive. If no keyframes are found an empty
tuple is returned.
keyframesRefit(refit, refit_tol, refit_preserve_extrema, refit_bezier, resample, resample_rate, resample_tol, range, range_start, range_end, bake_chop)
Performs a refitting operation with resampling and range controls.
refit
If set to true, a cubic refitting will be performed with the supplied refit options. If set to false, the refitting is skipped and only the resampling or range operation will be performed.
refit_tol
Refit Tolerance in absolute value.
refit_preserve_extrema
Preserves the keys that are local minima or maxima.
refit_bezier
If True
, the new keyframes will be set to use bezier() segments.
If False
, the new keyframes will be set to use cubic() segments.
resample
If True
, a resampling operation is performed prior to the refitting.
If False
, the channel is used as is.
resample_rate
Resample rate in frames. If set to 1.0, a keyframe will be added at every frame.
resample_tol
Resample Tolerance in frames. If set to 1.0, the resampling won’t happen if a frame exists within one frame.
range
If True
, the range_start and range_end arguments are used. It’s useful when baking cycles when using cycle/cycle offset or oscillate channel extrapolation.
If False
, the channel range will be used based on the first and last keyframes.
range_start
Start frame of the range.
range_end
End frame of the range.
bake_chop
A hou.parmBakeChop enumeration value.
refit_smooth
If True
, the new keyframes will have auto slopes applied to them.
If False
, the new keyframes use slopes chosen by the refitting algorithm.
isScoped()
→ bool
Returns whether this parameter’s channel is scoped. If it is scoped, then it is loaded in the animation editor.
isSelected()
→ bool
Returns whether this parameter’s channel is selected. If it is selected, then it is selected in the animation editor.
saveClip(file_name, start=None, end=None, sample_rate=0)
Saves the animation associated with this parameter to the clip file specified by ‹file_name›. The extension of ‹file_name› determines the format of the saved file.
You can use one of the following extensions:
-
.clip
: save animation as plain text (ASCII) clip file. -
.bclip
: save animation as a bclip (binary clip) file. -
.bclip.sc
: save animation as a bclip file using Blosc compression.
Set ‹sample_rate› to a non-zero, non-negative value to specify the sample_rate to be used for the clip file. For example, if the current frame rate is 24 (hou.fps()), and ‹sample_rate› is set to 12, the animation will be sampled every second frame since ‹sample_rate› is half of the current frame rate.
If ‹start› is not None
, start saving the animation from the specified
frame (inclusive).
Otherwise, the animation will be saved from the global start frame (inclusive).
Similarly, if ‹end› is not None
, stop saving the animation at the
specified frame (inclusive).
Otherwise, the animation will be saved until the global end frame (inclusive).
The global start and end frame are specified in the Global Animation Options window.
Raises a hou.OperationFailed exception if the parameter does not have animation.
Raises a hou.OperationFailed exception if there is an error saving the animation to file.
Raises a hou.InvalidInput exception if start >= end
. If specifying only
‹start›, ensure that the specified value is less than the global
end frame. Likewise, if specifying only ‹end›, ensure it is larger than
the global start frame.
loadClip(file_name, sample_rate=0, start=None)
Load animation for this parameter from the clip file specified by ‹file_name›. See hou.Parm.saveClip for the list of supported clip file formats.
Any tracks in the clip file that do not match this parameter’s hou.Parm.name will be ignored.
If ‹sample_rate› is set to a non-zero, non-negative value, the specified value will be used when loading the animation. For example, if the current frame rate is 24 (hou.fps()) and ‹sample_rate› is set to 12, the animation will be loaded with a keyframe at every second frame since ‹sample_rate› is half of the current frame rate.
‹start› specifies the frame the loaded animation should start from. By default the animation starts at the frame specified in the clip file.
Warning
Any existing keyframes for this parameter that are within the range of the loaded animation will be overwritten with the loaded data.
This function will raise a hou.OperationFailed exception if there is an error reading animation data from the file.
clipData(start=None, end=None, binary=True, use_blosc_compression=True, sample_rate=0)
→ str
for Python 2, bytes
for Python 3
Returns the clip data for this parameter. This method is similar to hou.Parm.saveClip, except that it returns the clip data (file contents) instead of saving the animation to a clip file.
‹start›, ‹end›, and ‹sample_rate› behave the same as in hou.Parm.saveClip.
If ‹binary› is True
, return binary clip data otherwise return plain
text (ASCII) clip data.
If ‹use_blosc_compression› is True
, blosc compress the binary clip data.
This cannot be used for plain text (ASCII) clip data.
The returned clip data is a bytes
object in Python 3 and a str
object in Python 2. See HOM binary data for
more information.
Raises a hou.OperationFailed exception if the parameter does not have animation.
Raises a hou.InvalidInput exception if start >= end
. If specifying only
‹start›, ensure that the specified value is less than the global
end frame. Likewise, if specifying only ‹end›, ensure it is larger than
the global start frame.
Raises a hou.InvalidInput exception if binary = False
and
use_blosc_compression = True
.
setClipData(data, binary=True, blosc_compressed=True, sample_rate=0, start=None)
Load animation for this parameter from the given clip ‹data›. This method is similar to hou.Parm.loadClip, except that it loads animation from the given clip data instead of a clip file.
‹sample_rate› and ‹start› behave the same as in hou.Parm.loadClip.
‹binary› and ‹blosc_compressed› specify the type of input data.
If ‹binary› is True
, the given data is binary clip data
otherwise, it is plain text (ASCII) clip data.
If ‹blosc_compressed› is True
, the given data is blosc compressed
binary data. This cannot be used for plain text (ASCII) clip data.
The data
passed into this method must be a bytes
object in Python 3
and a str
object in Python 2. See HOM binary data
support for more information.
Raises a hou.OperationFailed exception if the given data is invalid.
Raises a hou.InvalidInput exception if binary = False
and
blosc_compressed = True
.
setScope(on)
Changes the scope property of this parameter’s channel, which affects whether it is loaded in the animation editor.
setAutoscope(on)
Changes the autoscope property of the parameter. If this property is on, this parameter is automatically scoped when the object is selected.
setSelect(on)
Changes the select property of this parameter’s channel, which affects whether it is selected in the animation editor.
setAutoSelect(on)
Changes the autoselect property of the parameter. If this property is on, this parameter defines the default selection state when it is displayed in the animation editor.
setKeyframe(keyframe)
Sets a keyframe on this parameter.
Raises TypeError
if keyframe
is not of type
hou.BaseKeyframe. Raises hou.PermissionError if this parameter
is not writable.
setKeyframes(keyframes)
Sets multiple keyframe on this parameter. Calling this method is more efficient than calling hou.Parm.setKeyframe several times because it sends out only one update event to Houdini for the entire batch of keyframes that are set.
keyframes
must be a tuple or list of hou.BaseKeyframe objects.
Raises hou.PermissionError if this parameter is not writable.
setKeyframeExtrapolation(before, extrapol)
Sets a extrapolation on this parameter for time before the first keyframe or after the last keyframe. Extrapolation defines how a parm value is evaluated outside the keyframe range.
before
If set to true, the extrapolation for evaluations before the first keyframe will be set. If set to false, the extrapolation for evaluations after the last keyframe will be set.
extrapol
A hou.parmExtrapolate enumeration value.
This function will raise a hou.ObjectWasDeleted exception if it is invoked on a parameter that does not exist in Houdini.
This function will raise a hou.PermissionError exception if writing to the specified parameter is impossible.
This function will raise a hou.OperationFailed exception the parameter doesn’t have a valid animation channel.
setPending(value)
Sets the parameter value at the current frame and marks it as pending if the parameter is keyed.
Raises TypeError
if the type of value
does not match this
parameter’s type. Raises hou.PermissionError if this parameter is not
writable.
isPending()
→ bool
Returns whether this keyed parameter has been changed, but hasn’t been explicitly keyed.
Value ¶
unexpandedString()
→ str
Returns the contents of the parameter before dollar sign and back-tick expansion.
Examples of unexpanded strings would be “image$F.pic”, “$HIP/split.hda”,
or “chs('../font1/text')
”. If you were to call eval()
on them, Houdini would perform variable expansion and back-tick expression
evaluation, so you would get back something like “image1.pic” instead of
“image$F.pic”.
Because only string parameters will attempt to do dollar sign and string expansion, this method will raise hou.OperationFailed if called from a non-string parameter.
Suppose a string parameter contains keyframes. In this situation, Houdini
will not attempt to do string expansion on the parameter’s value, so calling
this method will raise hou.OperationFailed. Instead of calling this method,
you can call expression()
to access the first Keyframe’s expression. If
there are multiple keyframes, you can call keyframes()
to get a list of
hou.StringKeyframe objects and call expression()
on those objects to
retrieve the expression.
eval()
→ int
, float
, or str
Evaluates this parameter at the current frame and returns the result.
See also the evalAtFrame
and evalAtTime
methods.
evalAsFloat()
→ float
Evaluates this parameter at the current frame and returns the result as a float.
Raises TypeError
if the value cannot be converted to a float.
evalAsFloatAtFrame(frame)
→ float
Evaluates this parameter at a certain frame and returns the result as a float.
Raises TypeError
if the value cannot be converted to a float.
evalAsInt()
→ int
Evaluates this parameter at the current frame and returns the result as an integer.
Raises TypeError
if the value cannot be converted to an integer.
evalAsIntAtFrame(frame)
→ int
Evaluates this parameter at a certain frame and returns the result as an integer.
Raises TypeError
if the value cannot be converted to an integer.
evalAsNode()
→ hou.OpNode
Evaluates this parameter at the current frame and returns the result as a hou.OpNode.
If the parameter resolves to multiple node paths, None
will be returned.
See evalAsNodes
for this.
Raises TypeError
if the value cannot be converted to a hou.OpNode.
evalAsNodeAtFrame(frame)
→ hou.OpNode
Evaluates this parameter at a certain frame and returns the result as a hou.OpNode.
If the parameter resolves to multiple node paths, None
will be returned.
See evalAsNodesAtFrame
for this.
Raises TypeError
if the value cannot be converted to a hou.OpNode.
evalAsNodes()
→ tuple
of hou.OpNode
Evaluates this parameter at the current frame and returns the result as a tuple of hou.OpNode.
Raises TypeError
if the value cannot be converted to a hou.OpNode.
evalAsNodesAtFrame(frame)
→ tuple
of hou.OpNode
Evaluates this parameter at a certain frame and returns the result as a tuple of hou.OpNode.
Raises TypeError
if the value cannot be converted to a hou.OpNode.
evalAsString()
→ str
Evaluates this parameter at the current frame and returns the result as a string.
If you want the string contents of the parameter before variable expansion and expression evaluation then call hou.Parm.unexpandedString.
Raises TypeError
if the value cannot be converted to a string.
evalAsStringAtFrame(frame)
→ str
Evaluates this parameter at a certain frame and returns the result as a string.
If you want the string contents of the parameter before variable expansion and expression evaluation then call hou.Parm.unexpandedString.
Raises TypeError
if the value cannot be converted to a string.
evalAtTime(time)
→ int
, float
, or str
Evaluate this parameter at a given time and return the result as an integer, float or string.
See also evalAtFrame.
evalAtFrame(frame)
→ int
, float
, or str
Evaluate this parameter at a given frame and return the result as an integer, float or string.
See also evalAtTime.
evalAsRamp()
→ hou.Ramp
Evaluates this parameter at the current frame and returns the result as a ramp.
Raises TypeError
if the parameter is not a ramp.
evalAsRampAtFrame(frame)
→ hou.Ramp
Evaluates this parameter at a certain frame and returns the result as a ramp.
Raises TypeError
if the parameter is not a ramp.
evalAsGeometry()
→ hou.Geometry
Evaluates this parameter at the current frame and returns the result as a geometry.
Raises TypeError
if the parameter is not a geometry.
evalAsGeometryAtFrame(frame)
→ hou.Geometry
Evaluates this parameter at a certain frame and returns the result as a geometry.
Raises TypeError
if the parameter is not a geometry.
evalAsJSONMap()
→ dict of str
to str
Evaluates this parameter at the current frame and returns the result as a JSON map structure (i.e. Python dictionary).
Raises TypeError
or hou.OperationFailed if the parameter is
not a JSON map data parameter.
evalAsJSONMapAtFrame(frame)
→ dict of str
to str
Evaluates this parameter at a certain frame and returns the result as a JSON map structure (i.e. Python dictionary).
Raises TypeError
or hou.OperationFailed if the parameter is
not a JSON map data parameter.
evalAsNodePath()
→ str
Evaluates this parameter at the current frame and returns the result as an absolute node path.
If the parameter resolves to multiple node paths, an empty string will be
returned. See evalAsNodePaths
for this.
evalAsNodePathAtFrame(frame)
→ str
Evaluates this parameter at a certain frame and returns the result as an absolute node path.
If the parameter resolves to multiple node paths, an empty string will be
returned. See evalAsNodePathsAtFrame
for this.
evalAsNodePaths()
→ tuple
of str
Evaluates this parameter at the current frame and returns the result as a tuple of strings where each is an absolute node path.
evalAsNodePathsAtFrame(frame)
→ tuple
of str
Evaluates this parameter at a certain frame and returns the result as a tuple of strings where each is an absolute node path.
rawValue()
→ str
Returns the parameter’s raw text value without evaluation or expansion. If the parameter has an expression then the expression is returned otherwise the parameter’s plain text value is returned.
Setting ¶
set(value, language=None, follow_parm_reference=True)
Sets the parameter value at the current frame.
value
A float, integer, or string to set the parameter value to.
Pass in a hou.Ramp object, as the parameter value, to set the value of a ramp parameter. The ramp object’s type needs to match the target ramp’s type. Note that the hou.Ramp.colorType() information is ignored since the color type on a ramp parameter is read-only.
Pass in a hou.Geometry object, as the parameter value, to set the value of a geometry data parameter.
Pass in a hou.Parm object to create a channel reference from this parameter to the specified parameter.
language
This option only applies when setting to a hou.Parm value.
Specifies the expression language to use when creating a channel
reference from this parameter to the given parameter. Set this option
to an hou.exprLanguage object or None
to choose the default
language.
follow_parm_reference
This option only applies when setting to a hou.Parm value and it defines which hou.Parm gets modified.
When this option is set to True
then this method will first follow
current channel references on this hou.Parm to determine the
hou.Parm that will be modified. It acts to keep the chain of
references and will set a new channel reference on the hou.Parm
that doesn’t have one yet.
When False
, the current hou.Parm is modified directly and the
chain of references is broken if there was an existing channel reference.
If this parameter currently contains a channel reference to another parameter, then this method will follow channel references and change the value of the referenced parameter. If this is not the desired behavior, then first delete the channel reference with hou.Parm.deleteAllKeyframes or hou.Parm.revertToDefaults for string parameters that don’t have the channel reference embedded in their string value.
Raises TypeError
if the type of value
does not match the
type of this parameter. Raises hou.PermissionError if this
parameter is not writable.
See also hou.OpNode.setParms.
setFromParm(src)
Copies the value of an entire parameter, including channels, from the
provided src
parameter.
setFromParmDefaults(src)
Copies the value of an entire parameter, including channels, from the
provided src
parameter’s defaults.
Expression ¶
expression()
→ str
Returns this parameter’s expression.
For example, a parameter might contain the Python expression frame() * 2
.
In this case hou.Parm.eval at frame 2 would return the value 4,
while calling expression() would return the string frame() * 2
.
If the parameter does not contain an expression, this method will raise hou.OperationFailed. Also, if the parameter contains more than one keyframe then it could contain multiple different expressions, so it also raises hou.OperationFailed in that case.
This method is roughly equivalent to…
parm.keyframes()[0].expression()
See also the setExpression()
, expressionLanguage()
, keyframes()
,
and eval()
methods.
setExpression(expression, language=None, replace_expression=True)
Sets this parameter’s expression.
expression: A string containing the expression that will go inside the parameter.
language:
Either a hou.exprLanguage enumeration value or None
.
If language is None and the parameter does not already contain an expression, the language will be the node’s expression language. (See hou.OpNode.expressionLanguage.) Otherwise, if language is None and the parameter already has an expression, the expression language will not change.
replace_expression:
This parameter only has effect if the parameter already contains
keyframes. If it is True
, Houdini will replace the keyframe
before the current time with one containing the new expression.
Otherwise, it will always add a keyframe at the current time.
Note that this behavior matches what happens when you edit an
expression from Houdini’s parameter dialog.
Unlike hou.Parm.set, this method does not follow channel references.
That is, if this parameter is referencing another parameter and you call
setExpression()
, it change the channel reference expression into the
specified expression.
If the parameter does not already contain any keyframes, this method is roughly equivalent to setting a keyframe at frame 1, where the keyframe’s expression and language are the ones specified.
This method can be approximately implemented as follows:
def setExpression(self, expression, language=None, replace_expression=None) if self.template().type() == hou.parmTemplateType.String: k = hou.StringKeyframe() else: k = hou.Keyframe() k.setExpression(expression, language) if len(self.keyframes()): if replace_expression: k.setTime(self.effectiveKeyframeAtFrame(hou.frame()).time()) else: k.setTime(hou.time()) else k.setTime(0.0) self.setKeyframe(k)
See also the expression
, expressionLanguage
, and setKeyframe
methods, hou.OpNode.expressionLanguage, and
hou.OpNode.setExpressions.
expressionLanguage()
→ hou.exprLanguage enum value
Returns the parameter’s expression’s language.
If the parameter does not contain an expression, this method will raise hou.OperationFailed. Also, if the parameter contains more than one keyframe then it could contain multiple different expressions, so it also raises hou.OperationFailed in that case.
To change the expression language, use hou.Parm.setExpression and
explicitly specify the language:
parm.setExpression(parm.expression(), language)
.
This method is roughly equivalent to…
parm.keyframes()[0].expressionLanguage()
See also the expression()
, setExpression()
, keyframes()
,
and setExpressionLanguage()
methods.
isShowingExpression()
→ bool
Return whether this parameter is shown as an expression or as the
See also the showExpression()
method.
referenceExpression(parm, language=None, follow_parm_reference=True)
→ str
Returns an expression string that contains a channel reference from this
parameter to the specified parm
.
showExpression(on)
Sets the UI for the parm to show the expression instead of the value.
See also the isShowingExpression()
method.
References ¶
getReferencedParm()
→ hou.Parm
Returns the referenced parameter. If no parameter is referenced, returns this parameter.
parmsReferencingThis()
→ tuple
of hou.Parm
Return a tuple of all the parameters in the scene that have channel references to this parameter.
Defaults ¶
hasTemporaryDefaults()
→ bool
Returns whether a default has been explicitly set on the parameter.
See also the revertToDefaults()
and
revertToAndRestorePermanentDefaults()
methods.
isAtDefault(compare_temporary_defaults=True, compare_expressions=False)
→ bool
Returns whether the parameter is currently at its default.
compare_temporary_defaults
:
When ‹compare_temporary_defaults› is True, isAtDefault
also checks
compare_expressions
:
When ‹compare_Expressions› is True, isAtDefault
compares the actual
See also the revertToDefaults()
and
revertToAndRestorePermanentDefaults()
methods.
isAtRampDefault()
→ bool
Returns whether the ramp parameter is currently at its default.
This tests all of the multiparm parameters associated with the ramp by comparing to the special ramp default spare paramater data. Ramps with no default spare data will never be at default.
overwriteDefaults()
Overwrite the default value with the current parameter value.
revertToAndRestorePermanentDefaults()
Changes the value back to the default that ships with Houdini, and restores that default.
See also the revertToDefaults()
method, and
hou.ParmTuple.revertToAndRestorePermanentDefaults
revertToDefaults()
Change the value back to the default(s).
See also the revertToAndRestoreFactoryDefaults()
method.
revertToRampDefaults()
Change the value back to the default(s), removing all the non-default control points from the ramp.
Raises TypeError
if the parameter is not a ramp.
Hierarchy ¶
containingFolders()
→ tuple of str
Returns a tuple of strings corresponding to the names of the folders containing this parameter.
For example, if this parameter is in the Shading folder and the Shading folder is inside the Render folder, this method will return (“Render”, “Shading”). Note that by folder name, we mean the label used in the parameter dialog, not the internal parameter name.
Returns an empty tuple if this parameter is not inside a folder.
Note that this method does not return containing multi-parameters. To return the containing multi-parameter, if any, then call hou.Parm.parentMultiParm.
Note that calling this method on many parameters may be slow. For a faster alternative, see hou.OpNode.parmsInFolder.
See also the containingFolderSetParmTuples
method, and
hou.OpNode.parmTuplesInFolder.
containingFolderSetParmTuples()
→ tuple of hou.ParmTuple
Return a tuple of ParmTuples corresponding to the folders containing this parameter.
For example, if this parameter is in the Shading folder and the Shading folder is inside the Render folder, this method will return a tuple containing the Render parm tuple and the Shading parm tuple. Any parm tuples returned will be folder sets.
If this parameter is not inside a folder, an empty tuple is returned.
See also the containingFolders()
method, and
hou.OpNode.parmsInFolder and hou.OpNode.parmTuplesInFolder.
containingFolderIndices()
→ tuple of int
Return a tuple of indices corresponding to the folders containing this parameter. Each index refers to a folder in the corresponding folder set parameter.
This method can be implemented as follows:
def containingFolderIndices(self): return tuple( list(folder_set_parm_tuple.parmTemplate().folderNames()).index( folder_name) for folder_set_parm_tuple, folder_name in zip( parm.containingFolderSetParmTuples(), parm.containingFolders()))
This example makes a parameter visible in the parameter pane by opening all the folders containing it.
def makeParmVisible(parm): for folder_set_parm_tuple, folder_index in zip( parm.containingFolderSetParmTuples(), parm.containingFolderIndices()): folder_set_parm_tuple[0].set(folder_index)
Clipboard ¶
copyToParmClipboard()
Copies this to the parameter clipboard. See also hou.parmClipboardContents().
Metadata ¶
name()
→ str
Returns this parameter’s name.
tuple()
→ hou.ParmTuple
Returns the hou.ParmTuple associated with this parameter.
For example, calling this method on the Parm object for the translation parameter “tx”, would return a ParmTuple that contains Parm objects for the three translation parameters “tx”, “ty” and “tz”. If no tuple is associated with the parameter, then the parameter itself is returned in a tuple of size 1.
path()
→ str
Returns the full path to this parameter.
description()
→ str
Returns this parameter’s label.
node()
→ hou.OpNode
Returns the node on which this parameter exists.
parmTemplate()
→ hou.ParmTemplate
Returns the template for this parameter.
componentIndex()
→ int
Returns the component index of this parameter.
For example, the translation parameter along the x-axis, “tx”, would return a component index of 0, while the translation parameter along the y-axis, “ty” would return a component index of 1.
isLocked()
→ bool
Returns whether this parameter is locked (uneditable).
isSpare()
→ bool
Returns whether this parameter is a “spare” (user-defined) parameter.
isTimeDependent()
→ bool
Returns whether this parameter is time dependent, that is, its
value changes depending on the point on the timeline at which it’s
evaluated. For example the parameter has an expression containing
the $F
(current frame number) variable.
disable(on)
Sets the UI disable state of this parameter in its node. This is not the same as locking a parameter, as the underlying value can still be modified. It’s closer to what a disable-when conditional does, when a parameter is disabled automatically by it.
isDisabled()
→ bool
Returns the disable state of the parameter, ignoring the lock state. This can be used to read the result of a disable-when conditional.
It is recommended that hou.OpNode.updateParmStates is called before executing this method either in non-graphical Houdini or when the owner node has not yet been loaded into the Parameter Pane.
hide(on)
Sets the UI hidden state of this parameter in its node.
Calling this method has the same effect as changing the Invisible
checkbox on the Edit Parameter Interface
dialog, or hiding the parameter
with a hide-when conditional.
However, changing the UI state with this function is transient and does not affect node parameter templates, which means that the new state is not saved to .hip file and can be restored when refreshing the node to its spare parameter templates.
To permanently change the UI state of a parameter on a node, please use hou.ParmTemplate.hide instead:
parms = hou.node('/obj/node').parmTemplateGroup() p = parms.find('lookatpath') p.hide(True) parms.replace('lookatpath', p) hou.node('/obj/node').setParmTemplateGroup(parms)
isHidden()
→ bool
Returns the hidden state of the parameter. This can be used to read the result of a hide-when conditional.
It is recommended that hou.OpNode.updateParmStates is called before executing this method either in non-graphical Houdini or when the owner node has not yet been loaded into the Parameter Pane.
isVisible()
→ bool
Returns whether or not this parameter would be visible in the parameter dialog for this node. It checks both the parameter’s template, and the hidden state of the parameter. This is equivalent to the following code (but runs faster because it avoids creating the hou.ParmTemplate):
>>> p = hou.parm('/obj/geo1/tx') >>> not p.isHidden() and not p.parmTemplate().isHidden() True
isConstrained()
→ bool
Returns True if the Parm’s parent node is an OBJ that is cooked and has constraints.
lock(on)
Locks (lock(True)
) or unlocks (lock(False)
) this parameter
(this is, makes the value uneditable).
Raises hou.PermissionError if this parameter is part of a locked digital asset.
CHOPs ¶
overrideTrack()
→ hou.Track or None
Returns the CHOP track overriding this parameter, if any.
isOverrideTrackActive()
→ bool
Returns True if the CHOP track overriding this parameter is active.
createClip(parent_node, name, create_new, apply_immediately, current_value_only, create_locked, set_value_to_default)
→ hou.ChopNode
Creates a Channel CHOP representing this parameter. The Channel CHOP is created with the given name as a child of the given parent node. The parent_node is typically created via hou.OpNode.findOrCreateMotionEffectsNetwork.
create_new: Always create a new Channel CHOP. If set to False, then if a Channel CHOP already exists with the same name, it will be re-used. If the parameter already exists on the Channel CHOP, the older parameter will be removed first.
apply_immediately: If set to True, then the export flag on the Channel CHOP will be set.
current_value_only: If set to True, then only the current value of the parameter will be stored.
create_locked: If set to True, then the parameters are locked on creation.
set_value_to_default: If set to True, then the parameters are reverted to their default values on creation
appendClip(chop_node, apply_immediately, current_value_only, create_locked, set_value_to_default)
Appends this parameter to the specified Channel CHOP.
apply_immediately: If set to True, then the export flag on the Channel CHOP will be set.
current_value_only: If set to True, then only the current value of the parameter will be stored.
create_locked: If set to True, then the parameters are locked on creation.
set_value_to_default: If set to True, then the parameters are reverted to their default values on creation
Scripts ¶
pressButton(arguments={})
Emulates clicking a button parameter to trigger its callback script.
Raises hou.OperationFailed if the callback script could not be
run. An optional dictionary of arguments can be passed to the callback
script. Raises TypeError
if a n argument value type is unsupported.
Note
This can be called on any type parameter to trigger its callback script, it is not limited to only button parameters.
arguments
An optional dictionary of arguments for the callback script. The dictionary
is merged with the keyword values passed to the callback. The arguments values
are single values of the following types: int
, bool
, float
, str
.
pressScriptActionButton(arguments={})
Emulates clicking a script action button on a parameter to trigger its script. Raises hou.OperationFailed if the action script could not be run. An optional dictionary of arguments can be passed to the action script. Returns the result of the execution of the script.
Note
This can be called on any type parameter to trigger its script action, it is not limited to only button parameters.
arguments
An optional dictionary of arguments for the callback script. It lets you control the keyboard modifiers with boolean values for 'alt', 'shift', 'ctrl' and 'command'.
Multiparms ¶
insertMultiParmInstance(index)
Insert a new multi parm instance before the given index. To append a new
multi parm instance, set the index to be the current number of instances.
The current number can be queried by calling evalAsInt
on the this
parameter.
removeMultiParmInstance(index)
Removes the multi parm instance at the given index.
moveDownMultiParmInstance(index)
Perform a move down operation on a Multi Parm Instance at the given index.
This function will raise a hou.PermissionError exception if writing to the specified parameter is impossible.
This function will raise a hou.Error exception if the index is invalid or is the first index or the only index.
moveUpMultiParmInstance(index)
Perform a move up operation on a Multi Parm Instance at the given index.
This function will raise a hou.PermissionError exception if writing to the specified parameter is impossible.
This function will raise a hou.Error exception if the index is invalid or is the last index or the only index.
moveMultiParmInstances(moves)
Perform a sequence of move operations on Multi Parm Instances. The 'moves' argument must be an array of integers containing an even number of entries. Entries at the odd-numbered array positions represent a 'from' multi parm index. Entries at the even-numbered array positions represent the associated 'to' multi parm index.
-
To move the instance at index 2 up, 'moves' should be
[2,3]
. -
To move the instance at index 2 down, 'moves' should be
[2,1]
. -
To move the instance at index 0 to position 2, 'moves' should be
[0,2]
.
You can move multiple parm instances in one operation:
-
To move the first 2 instances at index 0 and 1 up to index 1, 'moves' should be
[0,1, 1,2]
.
This function will raise a hou.PermissionError exception if writing to the specified parameter is impossible.
This function will raise a hou.Error exception with descriptive text if the 'moves' argument doesn’t have an even number of entries or if an index is invalid.
isMultiParmInstance()
→ bool
Return whether this parameter is an instance of a multi parm. For example,
the pt0x
, pt1x
, pt2x
, etc. parameters in an add
SOP are instances
of a multiparm.
isMultiParmParent()
→ bool
Return whether this parameter is a parent multi parm, ie: the number of instances parameter.
parentMultiParm()
→ hou.Parm
Return the parent multi-parameter if this parameter is a multi-parameter instance and None otherwise.
multiParmInstanceIndices()
→ tuple of int
If this parameter is a multi-parameter instance, then return a tuple of indices of where the parameter appears in the multi-parameter block and any nested blocks. Indices for outer multi-parameter blocks are listed first.
For example if this parameter appears as the fourth instance in the multi-parameter block then (3,) is returned.
As another example if this parameter appears as the third instance in the multi-parameter block and the block itself appears as the first instance of an outer multi-parameter block then (0, 2) is returned.
multiParmInstances()
→ tuple
of hou.Parm
If this parameter corresponds to the number of instances for a multiparm, return all the parameters corresponding to all instances of this multiparm.
Returns an empty tuple if this parameter is not for a multiparm.
multiParmInstancesPerItem()
→ int
If this parameter corresponds to the number of instances for a multiparm, return number of parameters per instance.
Returns 0 if this parameter is not for a multiparm.
multiParmInstancesCount()
→ int
If this parameter corresponds to the number of instances for a multiparm, return number of parameters per instance.
Returns 0 if this parameter is not for a multiparm.
multiParmStartOffset()
→ int
If this parameter corresponds to the number of instances for a multiparm, return the starting index used when building multi parameter names. The default value is 1.
Returns 0 if this parameter is not for a multiparm.
Menus ¶
Misc ¶
asCode(brief=False, save_values=True, save_keyframes=True, save_keys_in_frames=False, save_flag_values=True, save_aliases=True, function_name=None)
→ str
Returns a script of Python statements that can be executed to
set the parameter’s values, flags and other properties.
To run the script, use either Python’s exec
or execfile
functions.
brief
When ‹brief› is True, the output script omits commands for setting values and flags that are set to the factory defaults. The script also omits keyframe commands that set unused values, slopes and accelerations. The value of ‹brief› must be either True or False.
save_values
When ‹save_values› is True, asCode
outputs commands
for setting the parameter’s value. The value of ‹save_values›
must be either True or False.
save_keyframes
When ‹save_keyframes› is True, asCode
outputs commands
for creating the parameter’s keyframes (if any). The value
of ‹save_keyframes› must be either True or False.
save_keys_in_frames
When ‹save_keys_in_frames› is True, asCode
outputs commands
for setting channel and key times in samples (frames) instead
of seconds. This parameter has no effect if ‹save_keyframes›
is set to False. The value of ‹save_keys_in_frames› must be either
True or False.
save_flag_values
When ‹save_flag_values› is True, asCode
outputs commands
for setting the parameter’s flag values. The value of
‹save_flag_values› must be either True or False.
save_aliases
When ‹save_aliases› is True, asCode
outputs commands for
setting the parameter’s channel alias. The value of
‹save_aliases› must be either True or False.
function_name
If ‹function_name› is specified, then the output script is wrapped in a Python function definition 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 wrapper function takes in a single argument which must be a reference to an existing node parameter. For symmetry, the function also returns the parameter reference.
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. p = hou.parm("/obj/geo1/tx") # Execute asCode and write the output script to file. script = p.asCode() f = open("set_parm_properties.py", "w") f.write(script) f.close() # Execute the script. This will set the values, flag values # and other properties on /obj/geo1's tx parameter. It will # also store a reference to the tx parameter into a variable # named 'hou_parm'. execfile("set_parm_properties.py")
Here is an example of saving the output into a function and then calling it in Houdini:
# Get a reference to the target parameter. p = hou.parm("/obj/geo1/tx") # Execute asCode and write the function definition to file. func = p.asCode(function_name="setParmProperties") f = open("parmlib.py", "w") f.write(func) f.close() # Call the function definition to set the properties on another # parameter. import parmlib hou_parm = parmlib.setParmProperties(node.parm("ty"))
uiBackgroundColor()
→ hou.Color
Returns the background color used to indicate the state of this parm in parm dialogs. Raises hou.NotAvailable if there is no UI.
As data ¶
See recipes for more information.
asData(**kwargs) -> dict[str, Any]
Returns a JSON-like structure representing this parameter.
setFromData(data: dict[str, Any]) -> None
Updates the settings and value of this parameter from the given data (as returned by Parm.asData()
).
valueAsData(**kwargs) -> Union[int, str, float, dict, list]
Returns a JSON-like value representing the value of this parameter.
setValueFromData(data: Union[int, str, float, dict, list]) -> None
Updates the value of this parameter from the given data (as returned by Parm.valueAsData()
).
multiParmInstancesAsData(**kwargs) -> Sequence[dict[str, Any]]
Returns a JSON-like structure representating any child instances of this multiparm.
setMultiParmInstancesFromData(data: Sequence[dict[str, Any]]) -> None
Sets the child instances of this multiparm from the given data (as returned by Parm.multiParmInstancesAsData()
).
rampPointsAsData(**kwargs) -> Sequence[dict[str, Any]]
Returns a JSON-like structure representing the points of this ramp parameter.
setRampPointsFromData(data: Sequence[dict[str, Any]]) -> None
Sets the points of this ramp parameter from the given data (as returned by Parm.rampPointsAsData()
).
templateAsData(children=True, **kwargs) -> dict[str, Any]
templateChildrenAsData(**kwargs) -> dict[str, Any]
insertTemplatesFromData(data: dict[str, Any], operation="insert_after", rename_conflicts=True) -> None
Inserts spare parameters relative to this parameter, from the given data.