AddKey (FCurve)

Introduced

3.0

Description

Adds a key at the given frame and returns the index of the new key. This method changes the overall shape of the fcurve. If you want to add a key along the existing profile (without affecting its shape, use the FCurve.InsertKeyAtFrame method instead.

Note: If the fcurve if locked then the method will raise an 'Access Denied' (E_ACCESSDENIED) error.

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 inherits the constraints of the nearest key within this range.

Scripting Syntax

    FCurve.AddKey( [Frame], [Value], [Tolerance], [Overwrite] )

C# Syntax

    Int32 FCurve.AddKey( Object in_Frame, Object in_Value, Double in_Tolerance, Boolean in_Overwrite );

Parameters

Parameter | Type | Description
Frame | Variant | Time in frames at which to add the key. Default Value: Current Time
Value | Variant | Value of the key. For standard and raw fcurves use a double value (VT_R8). For integer fcurves use a LONG (VT_I4) For boolean fcurves use a variant bool value (VT_BOOL,VARIANT_TRUE,VARIANT_FALSE) Default Value: The value on the existing curve at the given frame.
Tolerance | Double | Key tolerance Default Value: -1 Possible Values: • >0: Matches key between Frame - Tolerance and Frame + Tolerance • 0: Key must be exactly at frame • -1: Nearest 0.5 frame
Overwrite | Boolean | Overwrite existing keys. Use this to overwrite a key with a lock. Default Value: False

Return Value

Long

Examples

JScript Example

    /*
       This example illustrates how to add keys to an fcurve and how to use
       the editing recording feature so that only one undo event is put onto the
       undo/redo stack.
    */

    // Create a null
    Application.NewScene( "", false );
    var nullobj = ActiveSceneRoot.AddNull();

    // Create an fcurve on the posx parameter from the null
    var fc = nullobj.posx.AddFCurve();

    // Define the number of keys
    var nbkeys = 100 ;

    // Start editing the fcurve
    fc.BeginEdit();

    // Add keys to the fcurve
    for ( i=0; i<nbkeys; i++ )
    {
       val = (Math.sin( 1/(i+1) ) * 10);
       fc.AddKey( i, val );
    }

    // End editing the fcurve and put the undo event onto
    // the undo/redo stack
    fc.EndEdit();

See Also

FCurve.InsertKeyAtFrame | FCurveKey.Locked | FCurve.Resample | FCurve.RemoveKey

Autodesk Softimage v7.5