Inheritance |
|
Methods ¶
asJSON(brief=False, save_keys_in_frames=False)
→ dict
Returns a JSON dictionary that describes the keyframe. The dictionary
includes the keyframe time and the expression if it has been set. If the
save_keys_in_frames
parameter is set to True, a frame number is used
instead of a time.
See also the fromJSON method.
fromJSON(keyframe_dict)
Sets the keyframe time and expression 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 string keyframes this method returns hou.parmData.String.
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()
.