## StoreEnvironmentCacheToMixer

### Introduced

v4.0

### Description

Stores the environment cache as a new action in the mixer.

### Scripting Syntax

    oReturn = StoreEnvironmentCacheToMixer( EnvironmentCache, [Name], [AddClip] );

### Return Value

Returns the new action created as an ActionSource.

### Parameters

Parameter | Type | Description
--- | --- | ---
EnvironmentCache | ActionSource | Specify the cache to use. If the environment is not specified then the current environment is used. If there is no current environment then the task does nothing.
Name | String | Name of the new action.
AddClip | Boolean | True to apply the new actions as a clip on the mixer after storing. Default Value: False

### Examples

#### VBScript Example

    ' Create a simple simulation of two spheres falling on a grid
    CreatePrim "Sphere", "MeshSurface"
    SetValue "sphere.sphere.radius", 1
    Translate , -3, 7, 0, siAbsolute, siView, siObj, siXYZ, True, "Views.ViewC.FrontCamera", siXY, , , , , , , 0
    Duplicate "sphere", , 2, 1, 1, 0, 0, 1, 0, 1, , , , , , , , , , , 0
    Translate , -2, 12, 0, siAbsolute, siView, siObj, siXYZ, True, "Views.ViewC.FrontCamera", siXY, , , , , , , 0
    CreatePrim "Grid", "MeshSurface"
    SetValue "grid.grid.ulength", 50
    SetValue "grid.grid.vlength", 50
    ' Set the spheres as active rigid bodies and set their collision
    ' type to bounding sphere
    CreateActiveRigidBody "sphere1,sphere"
    SetValue "sphere1.RigidBodyProp.colltype,sphere.RigidBodyProp.colltype", Array(1, 1)
    ' Set the grid as a passive rigid body
    CreatePassiveRigidBody "grid"
    ' Add gravity
    CreateForce "Gravity"
    ' Turn on caching in the environment time control
    SetValue "Environments.Environment.simtimectrl.caching", True
    ' Go to the last frame so that the simulation computes and stores
    ' into the cache
    LastFrame
    Refresh
    ' Copy the cache to the mixer. We pass true as the addclip parameter.
    ' This means that a clip will also be added in the mixer on a new
    ' track. Also, having this parameter set to true will mute the
    ' simulation so that the mixer animation doesn't feedback back into the
    ' simulation.
    set oEnvironment = ActiveProject.ActiveScene.ActiveSimulationEnvironment
    StoreEnvironmentCacheToMixer oEnvironment.Caches(0), "SimulationRun", True
    ' Now if you playback. What you will see is the animation played
    ' from by mixer. You can mute the mixer track, reactivate the
    ' simulation, tweak some simulation parameters and store another
    ' cache into the mixer. Once you have a series of such actions,
    ' review them and chose the one that you prefer.