## PlotAndApplyActions

### Introduced

v7.5

### Description

Creates and returns new actions by plotting values from consecutive frames of an animation. Actions are created under models containing animated parameters matching the specified list and you can choose whether or not to apply the actions back to the model and then optionally delete them.

### Scripting Syntax

    oReturn = PlotAndApplyActions( [InputObj], [Name], [StartFrame], [EndFrame], [StepFrame], [FCurve Kind], [DefaultSegKind], [Fit FCurve], [Fit Tolerance], [ProcessContRots], [Apply], [Paste], [Delete] );

### Return Value

Returns the created actions (a XSICollection object). Returns nothing if you chose the Delete option.

### Parameters

Parameter | Type | Description
--- | --- | ---
InputObj | String | List of parameters to plot into actions. Default Value: Marked values in current selection
Name | String | Name for the actions Default Value: "Action"
StartFrame | Double | First frame to plot Default Value: 0
EndFrame | Double | Last frame to plot Default Value: 0
StepFrame | Double | Step between frames Default Value: 1
FCurve Kind | Integer | What kind of fcurve do we want to plot to? Default Value: 20
Possible Values: | Description:
10 | BOOLEAN (value true or false)
15 | INTEGER (staircase-like fcurve with integer values)
20 | STANDARD (fcurve with spline/linear/constant interpolation)
30 | RAWDATA (linear fcurve: less storage than a standard fcurve but with linear interpolation only)
DefaultSegKind | Integer | What kind of interpolation do we want for the resulting fcurves? Note: Only relevant when FCurveKind is 20 (Standard). Default Value: 3
Possible Values: | Description:
1 | CONSTANT
2 | LINEAR
3 | CUBIC
Fit FCurve | Boolean | Do we want to fit an fcurve through the plotted values? Default Value: False
Fit Tolerance | Double | What tolerance do we want for the fit? Default Value: 0.01
ProcessContRots | Boolean | Do we want to process rotation curves to ensure their continuity? Default Value: True
Apply | Boolean | Do we want to apply the actions after plotting them? Default Value: True
Paste | Boolean | If applying, should they be applied using paste (merging with existing fcurves on parameters)? Default Value: False
Delete | Boolean | After plotting and applying, do we want to delete the actions? Only valid if Apply is specified. Default Value: False

### Examples

#### JScript Example

    //
    // This example sets up one model with a sphere and another with a cone,
    // plots various parameters to an action source for each model,
    // and then prints out the new sources.
    //
    // Set up the scene.
    NewScene( null, false );
    var oSphere = CreatePrim( "Sphere", "NurbsSurface", "MySphere" );
    var oCone = CreatePrim( "Cone", "NurbsSurface", "MyCone" );
    CreateModel( oSphere, "SphereModel" );
    CreateModel( oCone, "ConeModel" );
    // Set some keys at frames 1 and 100 with it moving diagonally.
    Translate( oSphere, -6, 3, 0, siAbsolute, siView, siObj, siXYZ );
    SaveKey( oSphere + "/kine.local.pos", 1 );
    Translate( oSphere , 6, -3, 0, siAbsolute, siView, siObj, siXYZ );
    SaveKey( oSphere + "/kine.local.pos", 100 );
    Translate( oCone , 6, -3, 0, siAbsolute, siView, siObj, siXYZ );
    SaveKey( oCone + "/kine.local.pos", 1 );
    Translate( oCone , -6, 3, 0, siAbsolute, siView, siObj, siXYZ );
    SaveKey( oCone + "/kine.local.pos", 100 );
    // Plot the positions of the sphere and the Y position of the cone every two frames
    // between frames 40 and 60 and store the result in a standard fcurve with cubic
    // interpolation. Don't fit the fcurves and don't care about continuous rotations
    // since we're plotting positions. After plotting to actions, apply the plotted
    // animations back onto the sphere and the cone using "paste" so existing keys outside
    // the plot range are not affected. Don't delete the actions after applying them.
    var oParamsColl = new ActiveXObject( "XSI.Collection" );
    oParamsColl.Add( oSphere + ".kine.local.posx" );
    oParamsColl.Add( oSphere + ".kine.local.posy" );
    oParamsColl.Add( oSphere + ".kine.local.posz" );
    oParamsColl.Add( oCone + ".kine.local.posx" );
    var oActionsColl = PlotAndApplyActions( oParamsColl.GetAsText(),
                            "plot", 40, 60, 2, 20, 3, false, null, null, true, true, false );
    var iActionsCount = oActionsColl.Count;
    if( iActionsCount > 0 )
    {
            for( var i = 0; i < iActionsCount; i++ )
            {
                    var oAction = oActionsColl.Item( i );
                    var oSourceItemsFound = oAction.SourceItems;
                    var iSourceItemsCount = oSourceItemsFound.Count;
                    if( iSourceItemsCount > 0 )
                    {
                            Application.LogMessage( "Found the following source items in " + oAction + ":" );
                            for( var j = 0; j < iSourceItemsCount; j++ )
                            {
                                    Application.LogMessage( "\t" + oSourceItemsFound.Item( j ).Name );
                            }
                    }
                    else
                    {
                            Application.LogMessage( "No source items found in " + oAction + "." );
                    }
            }
    }
    else
    {
            Application.LogMessage( "No actions created." );
    }
    //---------------------------------------------------------
    // OUTPUT OF ABOVE SCRIPT IS:
    // INFO : Found the following source items in Sources.SphereModel.plot:
    // INFO :       MySphere.kine.local.posx
    // INFO :       MySphere.kine.local.posy
    // INFO :       MySphere.kine.local.posz
    // INFO : Found the following source items in Sources.ConeModel.plot:
    // INFO :       MyCone.kine.local.posx
    //---------------------------------------------------------

### See Also

PlotToActions PlotConstrainedTransformsToActions PlotKeyableToActions ApplyAction StoreAction DeleteObj