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