SaveKey

Description

Saves key frames on parameters at a given frame. When you invoke this command on a parameter not already driven by an FCurve, a new FCurve is automatically created.

The tolerance argument can be used to merge all keys within a certain range. The range is defined as Frame - Tolerance and Frame + Tolerance. The merged key will inherit the constraints of the nearest key within this range.

Scripting Syntax

SaveKey( [InputObjs], [Time], [Value], [Tolerance], [Layer], [ModifiedOnly], [AutokeyScope] );

Parameters

Parameter Type Description
InputObjs String List of animatable parameters (for example "cone*/kine.local.pos").

Default Value: If no argument is specified, the current marking is used.

Note: This command will fail if no argument is specified and no parameters are marked.

Time Double Frame at which to set the key.

Default Value: If no argument is specified, the current frame is used.

Value Number Key frame values.

Default Value: Parameter values at current frame.

Tolerance Double Frame tolerance

Default Value: Nearest 0.5 frame (-1)

Possible Values:

Description:

>0 Merge all keys between Frame - Tolerance and Frame + Tolerance
0 Key must be exactly at frame
-1 Nearest 0.5 frame
Layer Integer Animation layer to set keys on

Default Value: Current animation layer (-1)

ModifiedOnly Boolean If true keys will only be set for parameters that have been modified at the current frame

Default Value: False

AutokeyScope Integer Specifies whether keys will be set on all parameters or only those with existing fcurves or keys.

Default Value: All specified parameters (0)

Possible Values:

Description:

0 Key all specified parameters
1 Only key parameters that have an existing key at the given time
2 Only key parameters that have an existing fcurve

Examples

1. VBScript Example

'

'	This example demonstrates how you can use the SaveKey command with

'	or without marking parameters. This example saves position keys on 

'	the nulls using various techniques demonstrating the flexibility of

'	this command.

'

NewScene , false

' Specify the parameter to set, the frame at which to set it and the value to use

GetPrim "Null", "null"

SaveKey "null.kine.global.posx", 50, 3

SaveKey "null.kine.global.posy", 50, 3

SaveKey "null.kine.global.posz", 50, 3

' Instead of a string identifying the null, we can also use the Null 

' object's shortcut to the Parameter 

set n1 = GetPrim( "Null" )

SaveKey n1.posx, 50, 3

SaveKey n1.posy, 50, 3

SaveKey n1.posz, 50, 3

' You can also mark the parameters instead of specifying them

GetPrim "Null" 

SetMarking "kine.local.pos"

SaveKey , 50, 3

' This saves the same keys, but does not mark posx, posy, and posz

ClearMarking

GetPrim "Null"

SaveKey "/kine.local.pos", 50, 3

' You can also use the currently marked parameters at the current frame

GetPrim "Null" 

SetMarking "kine.local.pos"

Translate , 3, 3, 3

SetValue "PlayControl.Key", 50

SetValue "PlayControl.Current", 50

SaveKey

2. Python Example

#

# This example demonstrates how you can use the SaveKey command to define an FCurve 

# on a parameter and then change its interpolation type to Linear (the default is 

# cubic Bezier -- see the FCurve object's documentation for more details). 

#

from win32com.client import constants as c

# Create scene

Application.NewScene( "", 0 )

Application.GetPrim( "Null", "null" )

Application.CreatePrim( "Arc", "NurbsCurve" )

Application.SelectObj( "null", c.siSelectDefault, 1 )

Application.ApplyCns( "Path", "null", "arc" )

# Set some keys

Application.SaveKey( "null.kine.pathcns.perc", 1, 0 )

Application.SaveKey( "null.kine.pathcns.perc", 30, 25 )

Application.SaveKey( "null.kine.pathcns.perc", 75, 85 )

Application.SaveKey( "null.kine.pathcns.perc", 100, 100 )

# Get the fcurve from a string path using the GetSource command

col = Application.GetSource( "null.kine.pathcns.perc" )

fc = col(0)

# Alternatively, you can use the Dictionary.GetObject method to 

# get the parameter object and then use its Source method

pathperc = Application.Dictionary.GetObject( "null.kine.pathcns.perc" )

fc = pathperc.Source

# Get the fcurve interpolation type 

Application.LogMessage( fc.Interpolation )

# Change the fcurve from cubic Bezier (3) to linear (2) and then 

# print the interpolation type again

Application.SetCurveType( "null.kine.pathcns.perc", 2 )

Application.LogMessage( fc.Interpolation )

# Expected results: (siFCurveInterpolation: 1=constant; 2=linear; 3=bezier cubic)

#INFO : 3

#INFO : 2

See Also

SaveKeyOnKeyable SaveKeyOnMarkedKeyable FCurve.SetKey FCurve.SetKeys AddFCurve RemoveAnimation RemoveAllAnimation RemoveKey PrevKey NextKey FirstKey LastKey FCurve Parameter.Source