FCurve.RemoveKeys

Introduced

v3.0

Description

Removes all keys between StartFrame and EndFrame and returns the number of keys removed.

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.

C# Syntax

Int32 FCurve.RemoveKeys( Object in_StartFrame, Object in_EndFrame, Boolean in_OverrideKeyLock );

Scripting Syntax

oLong = FCurve.RemoveKeys( [StartFrame], [EndFrame], [OverrideKeyLock] );

Return Value

Long

Parameters

Parameter Type Description
StartFrame Variant The time in frames at which to start removing keys.

Default Value: The frame of the first key on the function curve.

EndFrame Variant The time in frames at which to end resampling.

Default Value: The frame of the last key on the function curve

OverrideKeyLock Boolean Override the FCurveKey.Locked value to force keys to be removed.

Default Value: false

Examples

JScript Example

/*

	This JScript example illustrates how to use the FCurve.RemoveKeys method

	to remove keys from the entire curve or from an interval on the fcurve.

*/

// Create a null

Application.NewScene( null, 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, 0, 10 );

var y = cpset.AddParameter( "Y", siInt4, empty, siAnimatable, "Y", "Y", empty, 5, 0, 100 );

var z = cpset.AddParameter( "Z", siBool, empty, siAnimatable, "Z", "Z", empty, true );

// Create some fcurves

var fc1 = x.AddFCurve();

var fc2 = y.AddFCurve();

var fc3 = z.AddFCurve();

// Add keys to the fcurves

fc1.Resample();

fc2.Resample();

fc3.Resample();

// Lock all the keys on fc3

for ( i=0; i<fc3.GetNumKeys(); i++ )

{

	key = fc3.GetKeyAtIndex(i);

	key.Locked = true;

}

var cKeys;

// Remove all keys between frame 1 and 10 and override the key lock

LogMessage( "keys in interval 1-10 : " +  fc3.GetNumKeys(1,10) );

cKeys = fc3.RemoveKeys( 1, 10, true );

LogMessage( "keys removed " + cKeys );

// Remove all the keys from fc1

LogMessage( "total num keys : " +  fc3.GetNumKeys() );

cKeys = fc1.RemoveKeys();

LogMessage( "keys removed " + cKeys );

// Remove all keys between frame 10 and 20

LogMessage( "keys in interval 10-20 : " +  fc3.GetNumKeys(10,20) );

cKeys = fc2.RemoveKeys( 10, 20 );

LogMessage( "keys removed " + cKeys );

// Outputs:

//INFO : "keys in interval 1-10 : 10"

//INFO : "keys removed 10"

//INFO : "total num keys : 90"

//INFO : "keys removed 100"

//INFO : "keys in interval 10-20 : 10"

//INFO : "keys removed 11"

See Also

FCurve.Locked FCurve.RemoveKey FCurve.RemoveKeyAtIndex FCurve.RemoveKeysAtIndex