hou.BaseKeyframe
class
Abstract base class for all keyframe class.
Subclasses: hou.Keyframe , hou.StringKeyframe
Methods
asCode(self, 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
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 value-
Returns the type that the keyframe evaluates to.
expression(self)→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 if an expression has not been set.
See
setExpression()andisExpressionSet(). expressionLanguage(self)→ hou.exprLanguage enum value-
Returns the keyframe’s expression’s language.
This function raises hou.KeyframeValueNotSet if an expresion language has not ben set.
See
setExpression(), andisExpressionLanguageSet(). frame(self)→double-
Returns 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.ParmisExpressionLanguageSet(self)→bool-
Returns whether the keyframe expression’s language is set.
See
setExpression()andexpressionLanguage(). isExpressionSet(self)→bool-
Returns whether the keyframe’s expression is set.
See
setExpression()andexpression(). isLocked(self)→boolisParmReference(self)→boolisTimeDependent(self)→boolisTimeSet(self)→bool-
Returns whether the keyframe’s time is set.
See
setTime()andtime(). Keyframe(self)lock(self, value=None)moveToIntegerKeyframes(self, mode)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)→double-
Returns the keyframe’s time in seconds.
This function raises if the time or frame has not been set.
See
setTime()andsetFrame().