FCurve.GetKeyFrame

Introduced

v3.0

Description

Returns the key time in frames of the key at the specified index.

Note: If the index is out of range then the method raises an 'Invalid argument' (E_INVALIDARG) error.

C# Syntax

Double FCurve.GetKeyFrame( Int32 in_Index );

Scripting Syntax

oDouble = FCurve.GetKeyFrame( Index );

Return Value

Double

Parameters

Parameter Type Description
Index Long Index of the key. Must be a value between 0 and (number of keys - 1).

Examples

JScript Example

/*
	This JScript example illustrates how to use the GetKeyFrame() method 
	to quickly look up an key's frame value.
*/
// 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()
// Use the Resample method to add keys to the fcurve on every second frame
var empty;
fc.NoKeyValue = Math.random() * 100;
fc.Resample( empty, empty, 2 );
var index, frame, value;
// Print out all key frame/value pairs
for ( index=0; index<fc.GetNumKeys(); index++ )
{
	frame = Math.round( fc.GetKeyFrame( index ) );
	value = fc.GetKeyValue( index );
	LogMessage( "key" + index + " frame = " + frame + " value = " + value );	
}
// Outputs:
//INFO : key0 frame = 1 value = 66.7755833336558
//INFO : key1 frame = 3 value = 66.7755833336558
//INFO : key2 frame = 5 value = 66.7755833336558
//	...etc.
//INFO : key48 frame = 97 value = 66.7755833336558
//INFO : key49 frame = 99 value = 66.7755833336558
//INFO : key50 frame = 100 value = 66.7755833336558

See Also

FCurveKey.Time FCurve.KeyExists FCurve.GetKeyValue FCurve.GetKeyIndex