FCurve.InsertKeyAtFrame

Introduced

v7.5

Description

Inserts a key at the current time or at the time specified by the frame argument. Unlike FCurve.AddKey, this method maintains the shape of the fcurve.

C# Syntax

Boolean FCurve.InsertKeyAtFrame( Object in_Frame );

Scripting Syntax

oBoolean = FCurve.InsertKeyAtFrame( [Frame] );

Return Value

Boolean (true if the FCurveKey is successfully added)

Parameters

Parameter Type Description
Frame Variant The key time in frames.

Default Value: The current time

Examples

JScript Example

/*
	This example illustrates how to insert keys in an fcurve.
*/
// Create a cube 
NewScene(null, false);
CreatePrim("Cube", "MeshSurface");
// Create an fcurve on the posx parameter of the cube
SaveKey("cube.kine.local.posx", 1, 0);
SaveKey("cube.kine.local.posx", 30, 5);
// Insert a key at frame 10
var fc = Application.Selection(0).posx.Source;
var bIsKeyInsertedAtFrame10 = fc.InsertKeyAtFrame(10);
Application.LogMessage("Key inserted at frame 10 = " + bIsKeyInsertedAtFrame10);
// Move to the frame 20
SetValue("PlayControl.Key", 20);
SetValue("PlayControl.Current", 20);
// Insert a key at the current frame
fc = Application.Selection(0).posx.Source;
var bIsKeyInsertedAtCurrentFrame = fc.InsertKeyAtFrame();
Application.LogMessage("Key inserted at current frame (frame 20) = " + bIsKeyInsertedAtCurrentFrame);
// Open the Animation Editor
SelectObj("cube", null, true);
OpenView("Animation Editor");
// Outputs:
//INFO : Key inserted at frame 10 = true
//INFO : Key inserted at current frame (frame 20) = true

See Also

FCurve.AddKey