FCurve.RemoveKeyAtIndex

Introduced

v3.0

Description

Removes the key at the specified index.

Note: If the fcurve is locked then the method raises an 'Access Denied' (E_ACCESSDENIED) error. Key locks can be overridden using the OverrideKeyLock argument.

Scripting Syntax

FCurve.RemoveKeyAtIndex( Index, [OverrideKeyLock] );

Parameters

Parameter Type Description
Index Long Index of the key; must be a value between 0 and (number of keys - 1).
OverrideKeyLock Boolean Override the FCurveKey.Locked value to force the key to be removed.

Default Value: false

Examples

JScript Example

/*
        This JScript example illustrates how to use the FCurve.RemoveKeyAtIndex method
        to remove a key at a specified index.
*/
// Create a null
Application.NewScene( "", false );
var nullobj = ActiveSceneRoot.AddNull();
var empty;
// Create a custom property set on the null
var cpset = nullobj.AddCustomProperty( "CustomPSet" );
var x = cpset.AddParameter( "X", siDouble, empty, siAnimatable, "X", "X", empty, 0.25, -100, 100 );
var y = cpset.AddParameter( "Y", siDouble, empty, siAnimatable, "Y", "Y", empty, 0.25, -100, 100 );
// Create some fcurves
var fc1 = x.AddFCurve();
var fc2 = y.AddFCurve();
// Start editing the fcurves
fc1.BeginEdit();
fc2.BeginEdit();
// Add keys to the fcurves
fc1.Resample();
fc2.Resample();
// Assign random values to the keys
for ( i=0; i<fc1.GetNumKeys(); i++ )
{
        fc1.GetKeyAtIndex(i).Value = ( Math.random() * 200 ) - 100;
        // Copy the value to fc2 for comparison
        fc2.GetKeyAtIndex(i).Value = fc1.GetKeyValue(i);
}
var cKeys = fc1.GetNumKeys();
Application.LogMessage( "total num keys : " +  cKeys );
// Remove all keys that have an absolute value greater than 75
for ( i=cKeys-1; i>0; i-- )
{
        if ( Math.abs( fc1.GetKeyValue(i) ) > 75 ) 
        {
                fc1.RemoveKeyAtIndex(i);
        }       
}
Application.LogMessage( "total num keys : " +  fc1.GetNumKeys() );
// End editing fcurve
fc2.EndEdit();
fc1.EndEdit();
// Outputs:
//INFO : "total num keys : 100"
//INFO : "total num keys : 74"

See Also

FCurve.RemoveKey FCurve.RemoveKeysAtIndex FCurve.RemoveKeys