FCurve.KeyExists

Introduced

v3.0

Description

Returns true if a key exists at the specified frame.

C# Syntax

Boolean FCurve.KeyExists( Object in_Frame, Double in_Tolerance );

Scripting Syntax

oBoolean = FCurve.KeyExists( Frame, [Tolerance] );

Return Value

Boolean

Parameters

Parameter Type Description
Frame Variant The key time in frames at which to look for a key.
Tolerance Double Key tolerance.

Default Value: -1

Possible Values:

Description:

>0 Matches key between Frame - Tolerance and Frame + Tolerance
0 Key must be exactly at frame
-1 Nearest 0.5 frame

Examples

JScript Example

/*

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

	to find keys on an fcurve.

*/

// Create a null

Application.NewScene( null, false );

var nullobj = ActiveSceneRoot.AddNull();

// Create an fcurve on the posx parameter from the null

var fc = nullobj.posx.AddFCurve();

// Define some random keys

var nbkeys = 10;

var arraysize = nbkeys * 2;

var keys = new Array( 2 * nbkeys );

var i = 0, empty;

offset = -50;

for ( i=0; i<arraysize; i+=2 )

{

	keys[i] = offset + Math.random() * 100 ;

	keys[i+1] = Math.cos( Math.random() ) * 10;

}

keys.sort();

// Set the keys on the fcurve

fc.SetKeys( keys );

// Find the random keys

for ( i=-50; i<50; i++ )

{

	if ( fc.KeyExists(i) )

	{

		LogMessage( "found key near frame " + i );

	}

	var ckeys = fc.GetNumKeys( i - 0.5, i + 0.5 )

	if ( ckeys > 1 )

	{

		LogMessage( "found "+ ckeys + " keys around frame " + i );

	}

}

// Outputs:

//INFO : found key near frame -21

//INFO : found key near frame -20

//INFO : found key near frame -7

//INFO : found key near frame -6

//INFO : found key near frame -5

//INFO : found key near frame -4

//INFO : found 2 keys around frame -4

//INFO : found key near frame -3

//INFO : found key near frame -2

//INFO : found key near frame 5

//INFO : found key near frame 6

//INFO : found key near frame 7

//INFO : found key near frame 8

//INFO : found key near frame 9

//INFO : found key near frame 10

See Also

FCurve.GetKey