FCurve.GetKeyValue

Introduced

v3.0

Description

Returns the value of the key at the specified index. The type of value that is returned depends on the type of fcurve used as follows:

Standard and raw fcurves return a double value (VT_R8)

Integer fcurves return a LONG (VT_I4)

Boolean fcurves return a variant bool value (VT_BOOL,VARIANT_TRUE,VARIANT_FALSE)

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

C# Syntax

Object FCurve.GetKeyValue( Int32 in_Index );

Scripting Syntax

oVariant = FCurve.GetKeyValue( Index );

Return Value

Variant

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 GetKeyValue() method 

	to quickly look up a key's 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()

// Create a custom property set on the null

var cpset = nullobj.AddCustomProperty( "CustomPSet" );

var empty;

var x = cpset.AddParameter( "X", siDouble, empty, siAnimatable, "X", "X", empty, 5, 0, 5 );

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

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

var fc1 = x.AddFCurve();

var fc2 = y.AddFCurve();

var fc3 = z.AddFCurve();

// Use the Resample method to add keys to the fcurve on every second frame

fc1.NoKeyValue = Math.random() * 100;

fc2.NoKeyValue = Math.random() * 100;

fc3.NoKeyValue = true;

fc1.Resample( empty, empty, 2 );

fc2.Resample( empty, empty, 2 );

fc3.Resample( empty, empty, 2 );

printfc( fc1 );

printfc( fc2 );

printfc( fc3 );

// Print out all key frame/value pairs

function printfc(fc)

{

	var index;

	for ( index=0; index<fc.GetNumKeys(); index++ )

	{

		LogMessage( "key" + index + " frame = " 

			+ Math.round(fc.getkeyframe(index))  

			+ " value = " + fc.getkeyvalue(index) 

		);	

	}

}

// Outputs:

//INFO : key0 frame = 1 value = 24.42401859658091

//INFO : key1 frame = 3 value = 24.42401859658091

//INFO : key2 frame = 5 value = 24.42401859658091

//	etc...

//INFO : key48 frame = 97 value = 1

//INFO : key49 frame = 99 value = 1

//INFO : key50 frame = 100 value = 1

See Also

FCurveKey.Value FCurve.GetKeyFrame FCurve.GetKeyValue FCurve.GetKeyIndex