Inheritance |
|
Methods ¶
__init__(values)
Return a new Keyframe object. You can pass no parameters (the result will have no value set), a float value, a float value and float time, or a Keyframe object.
accel()
→ double
Returns the acceleration leaving the keyframe.
This function raises hou.KeyframeValueNotSet if the acceleration has not been set.
asJSON(brief=False, save_keys_in_frames=False)
→ dict
Returns a JSON dictionary that represents the keyframe. The dictionary
includes the frame time, value/expression, and the slope and acceleration
parameters. If the brief
parameter is set to True a smaller set of
key/value pairs are included in the dictionary to reduce space usage.
If the save_keys_in_frames
parameter is True the dictionary uses a frame
number instead of a time value.
See also the fromJSON method.
fromJSON(keyframe_dict)
Sets the keyframe time, value and parameters using the key/value pairs from a JSON dictionary.
See also the asJSON method.
evaluatedType()
→ hou.parmData enum value
Return the data type of the keyframe’s evaluated value. For keyframes storing numerical values this method returns hou.parmData.Float.
inAccel()
→ double
Returns the acceleration entering the keyframe.
This method raises hou.KeyframeValueNotSet if the acceleration has not been set or it is tied.
inSlope()
→ double
Returns the slope entering the keyframe.
This method raises hou.KeyframeValueNotSet if the slope has not been set or the slope is tied.
interpretAccelAsRatio(on)
Sets whether Houdini should interpret the acceleration values entering and leaving the keyframe as a single ratio. When set to True, the ratio of the in-acceleration to out-acceleration is always maintained. If, for example, the in-acceleration is made to be twice as large using the Animation Editor, then the out-acceleration will automatically be adjusted to be twice as large as well. This is the default behavior for Houdini keyframes.
inValue()
→ double
Returns the value entering the keyframe.
This method raises hou.KeyframeValueNotSet if the value has not been set or the value is tied.
isAccelInterpretedAsRatio()
→ bool
Returns True if the acceleration values entering and leaving the keyframe are interpreted as a ratio by Houdini.
isAccelSet()
→ bool
Returns True if the acceleration entering or leaving the keyframe has been set.
isAccelTied()
→ bool
Returns True if the acceleration entering the keyframe has not been set.
isAccelUsed()
→ bool
Returns True if the acceleration entering or leaving the keyframe is being used.
isInSlopeAuto()
→ bool
Returns True if the slope entering the keyframe is set to automatic.
isSlopeAuto()
→ bool
Returns True if the slope leaving the keyframe is set to automatic.
isSlopeSet()
→ bool
Returns True if the slope entering or leaving the keyframe has been set.
isSlopeTied()
→ bool
Returns True if the slope entering the keyframe has not been set.
isSlopeUsed()
→ bool
Returns True if the slope entering or leaving the keyframe is being used.
isValueSet()
→ bool
Returns True if the value entering or leaving the keyframe has been set.
isValueTied()
→ bool
Returns True if the value entering the keyframe has not been set.
isValueUsed()
→ bool
Returns True if the value entering or leaving the keyframe is being used.
setAccel(accel)
Sets the acceleration leaving the keyframe.
setInAccel(in_accel)
Sets the acceleration entering the keyframe. Sets the acceleration leaving the keyframe, if not already set. Unties the acceleration.
setInSlope(in_slope)
Sets the slope entering the keyframe. Sets the slope leaving the keyframe, if not already set. Unties the slope.
setInSlopeAuto(on)
Sets the slope entering the keyframe to automatic.
setInValue(in_value)
Sets the value entering the keyframe. Sets the value leaving the keyframe, if not already set. Unties the value.
setSlope(slope)
Sets the slope leaving the keyframe.
setSlopeAuto(on)
Sets the slope leaving the keyframe to automatic.
setValue(value)
Sets the value leaving the keyframe.
slope()
→ double
Returns the slope leaving the keyframe.
This method raises hou.KeyframeValueNotSet if the slope has not been set.
unsetInAccel()
Unsets the acceleration entering the keyframe and tie the acceleration.
unsetInSlope()
Unsets the slope entering the keyframe and tie the slope.
unsetInValue()
Unsets the value entering the keyframe and tie the values.
useAccel(on)
Sets the acceleration used flag.
useSlope(on)
Sets the slope used flag.
useValue(on)
Sets the value used flag.
value()
→ double
Returns the value leaving the keyframe.
This method raises hou.KeyframeValueNotSet if the value has not been set.
Methods from hou.BaseKeyframe ¶
asCode(brief=False, save_keys_in_frames=False, function_name=None)
→ str
Returns a script of Python statements that can be executed to create
the keyframe. To run the script, use either Python’s exec
or execfile
functions.
brief
When ‹brief› is True, the output script omits commands for setting unused values, slopes and accelerations. This parameter only applies to non-string keyframes. The value of ‹brief› 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. The value of ‹save_keys_in_frames› 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 function returns a reference to the newly created keyframe object.
Here is an example of saving the output to a file and then loading it back into Houdini:
# Get a reference to the target keyframe. tx_parm = hou.parm("/obj/geo1/tx") key = tx_parm.keyframes()[0] # Execute asCode and write the output script to file. script = key.asCode() f = open("create_key.py", "w") f.write(script) f.close() # Execute the script. The new keyframe will be stored # in the 'hou_keyframe' variable. execfile("create_key.py") # Commit the keyframe back into the node parameter. tx_parm.setKeyframe(hou_keyframe)
Here is an example of saving the output into a function and then calling it in Houdini:
# Get a reference to the target keyframe. tx_parm = hou.node("/obj/geo1").Parm("tx") key = tx_parm.keyframes()[0] # Execute asCode and write the function definition to file. func = key.asCode(function_name="createKeyframe") f = open("keylib.py", "w") f.write(func) f.close() # Call the function definition. import keylib hou_keyframe = keylib.createKeyframe() # Commit the keyframe back into the node parameter. tx_parm.setKeyframe(hou_keyframe)
expression()
→ str
Returns the keyframe’s expression. For example, in cases where the keyframe has had two values set the interpolating function is returned e.g. “bezier()”, “spline()” etc.
This function raises hou.KeyframeValueNotSet if an expression has not been set.
See setExpression()
and isExpressionSet()
.
expressionLanguage()
→ hou.exprLanguage enum value
Returns the keyframe’s expression’s language.
This function raises hou.KeyframeValueNotSet if an expression language has not ben set.
See setExpression()
, and isExpressionLanguageSet()
.
frame()
→ double
Returns the keyframe’s frame number.
This function raises hou.KeyframeValueNotSet if the frame or time has not been set.
See setFrame()
and setTime()
.
isExpressionLanguageSet()
→ bool
Returns whether the keyframe expression’s language is set.
See setExpression()
and expressionLanguage()
.
isExpressionSet()
→ bool
Returns whether the keyframe’s expression is set.
See setExpression()
and expression()
.
isTimeSet()
→ bool
Returns whether the keyframe’s time is set.
See setTime()
and time()
.
setExpression(expression, language=None)
Sets the keyframe’s expression and language.
This function raises TypeError if language
is not a value from hou.exprLanguage.
See expression()
, expressionLanguage()
, isExpressionSet()
, isExpressionLanguageSet()
.
setFrame(frame)
Sets the keyframe’s frame number. Using the number of frames per second (hou.fps()), setting the frame number also sets the time. For example, with an fps of 24, then setting the frame number to 49 will set the time to 2 seconds.
See frame()
.
setTime(time)
Sets the keyframe’s time in seconds. Using the number of frames per second (hou.fps()), setting the time also sets the frame number. For example, with an fps of 24, then setting the time to 2 seconds will set the frame number to 49.
See time()
.
time()
→ double
Returns the keyframe’s time in seconds.
This function raises hou.KeyframeValueNotSet if the time or frame has not been set.
See setTime()
and setFrame()
.