/*
This JScript example illustrates how to add keys to an fcurve and
then how to access the key using its index.
*/
// 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 the number of keys
var nbkeys = 100;
// Start editing the fcurve
fc.BeginEdit();
// Add keys to the fcurve
var key, val, index, frame;
for ( frame=1; frame<=nbkeys; frame++ )
{
val = ( Math.sin( 1/frame ) * 10 )
index = fc.AddKey( frame, val );
// Get key using index
key = fc.GetKeyAtIndex( index );
// Lock key
key.Locked = true;
}
// End editing the fcurve and put the undo event onto
// the undo/redo stack
fc.EndEdit();
|