Abstract base class for all keyframe class.
Methods
| asCode | 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. |
| evaluatedType | Returns the type that the keyframe evaluates to. |
| expression | 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. |
| expressionLanguage | Returns the keyframe’s expression’s language. |
| frame | Returns the keyframe’s frame number. |
| isExpressionLanguageSet | Returns whether the keyframe expression’s language is set. |
| isExpressionSet | Returns whether the keyframe’s expression is set. |
| isTimeSet | Returns whether the keyframe’s time is set. |
| setExpression | Sets the keyframe’s expression and language. |
| setFrame | 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. |
| setTime | 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. |
| time | Returns the keyframe’s time in seconds. |
asCode(self, brief=False, save_keys_in_frames=False, function_name=None)→strReturns a script of Python statements that can be executed to create the keyframe. To run the script, use either Python’s
execorexecfilefunctions.briefWhen 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_framesWhen save_keys_in_frames is True,
asCodeoutputs 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_nameIf 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)
evaluatedType(self)→ hou.parmData enum valueReturns the type that the keyframe evaluates to.
expression(self)→strReturns 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()andisExpressionSet().expressionLanguage(self)→ hou.exprLanguage enum valueReturns the keyframe’s expression’s language.
This function raises hou.KeyframeValueNotSet if an expresion language has not ben set.
See
setExpression(), andisExpressionLanguageSet().frame(self)→doubleReturns the keyframe’s frame number.
This function raises hou.KeyframeValueNotSet if the frame or time has not been set.
See
setFrame()andsetTime().getReferencedParm(self)→ hou.ParmThis feature is not yet implemented
isExpressionLanguageSet(self)→boolReturns whether the keyframe expression’s language is set.
See
setExpression()andexpressionLanguage().isExpressionSet(self)→boolReturns whether the keyframe’s expression is set.
See
setExpression()andexpression().isLocked(self)→boolThis feature is not yet implemented
isParmReference(self)→boolThis feature is not yet implemented
isTimeDependent(self)→boolThis feature is not yet implemented
isTimeSet(self)→boolReturns whether the keyframe’s time is set.
See
setTime()andtime().Keyframe(self)This feature is not yet implemented
lock(self, value=None)This feature is not yet implemented
moveToIntegerKeyframes(self, mode)This feature is not yet implemented
setExpression(self, expression, language=None)Sets the keyframe’s expression and language.
This function raises hou.TypeError if
languageis not a value from hou.exprLanguage.See
expression(),expressionLanguage(),isExpressionSet(),isExpressionLanguageSet().setFrame(self, 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(self, 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(self)→doubleReturns the keyframe’s time in seconds.
This function raises hou.KeyframeValueNotSet if the time or frame has not been set.
See
setTime()andsetFrame().