OffsetKeys (FCurve)

Introduced

6.0

Description

Offsets fcurve keys in time or value by a relative amount.

Note: If the KeyCollection is from a different fcurve then the method will raise an 'Invalid argument' (E_INVALIDARG) error.

If the FCurve is locked then the method raises an 'Access Denied' (E_ACCESSDENIED) error.

Scripting Syntax

    FCurve.OffsetKeys( KeyCollection, [FrameOffset], [ValueOffset] )

C# Syntax

    FCurve.OffsetKeys( FCurveKeyCollection in_Keys, Object in_FrameOffset, Object in_ValueOffset );

Parameters

Parameter | Type | Description
KeyCollection | FCurveKeyCollection | The keys to offset.
FrameOffset | Double | The relative amount to offset the fcurve's time. Can be positive or negative. Default Value: 0
ValueOffset | Double | The relative amount to offset the fcurve's values. Can be positive or negative. Default Value: 0

Examples

JScript Example

    //
    // This example illustrates how to shift fcurve keys in both time and value.

    // Create a new scene
    NewScene(null, false);

    // Create a null
    oNull = Application.GetPrim("Null");

    // Get the posx parameter of the null
    oPosX = oNull.posx

    // Create array of time-value pairs
    aKeys = new Array( 0.00, 5.00,
                  1.00, 6.00,
                  2.00, 7.00,
                  3.00, 8.00,
                  4.00, 9.00,
                  5.00, 10.00 );

    // Create an empty FCurve
    oFCurve = oPosX.AddFCurve2( null, siStandardFCurve );

    // Set the fcurve keys
    oFCurve.SetKeys( aKeys );

    Application.LogMessage( 'Before Offset:', siInfo );
    for (var i = 0; i < oFCurve.Keys.Count; i++)
    {
       Application.LogMessage( 'Time: ' + oFCurve.Keys(i).Time + ', Value: ' + oFCurve.Keys(i).Value, siInfo );
    }

    oFCurve.OffsetKeys( oFCurve.GetKeysBetween(2,4), 0.2, -5 );

    Application.LogMessage( 'After Offset:', siInfo );
    for (var i = 0; i < oFCurve.Keys.Count; i++)
    {
       Application.LogMessage( 'Time: ' + oFCurve.Keys(i).Time + ', Value: ' + oFCurve.Keys(i).Value, siInfo );
    }

    // Produces the following output:
    //
    //INFO : Before Offset:
    //INFO : Time: 0, Value: 5
    //INFO : Time: 1, Value: 6
    //INFO : Time: 2, Value: 7
    //INFO : Time: 3, Value: 8
    //INFO : Time: 4, Value: 9
    //INFO : Time: 5, Value: 10
    //INFO : After Offset:
    //INFO : Time: 0, Value: 5
    //INFO : Time: 1, Value: 6
    //INFO : Time: 2.2, Value: 2
    //INFO : Time: 3.2, Value: 3
    //INFO : Time: 4.2, Value: 4
    //INFO : Time: 5, Value: 10

See Also

FCurve.Offset | FCurve.Scale | FCurve.ScaleKeys

Autodesk Softimage v7.5