How to set the animation environment and save an ArcMap animation as a file


This sample illustrates how to set the ArcMap animation environment and save an ArcMap animation as a file. When an animation is saved, the animation environment settings and all animation tracks and keyframes will be persisted.

How to use

  1. Open a map document with one or more animation tracks present;
  2. Copy and paste the following code to the VB editor in ArcMap;
  3. Make sure that "ESRI Animation Object Library" and "ESRI AnimationUI Object Library" are checked in the References dialog box of the VBA project;
  4. Run the macro "Map_Save_Animation";
  5. Check the location where you saved the animation file to verify that the animation was saved.
[VBA]
Public Sub Map_Save_Animation()
    'Find the animation extension
    Dim pUID As New UID
    pUID.Value = "esriAnimation.AnimationExtension"
    Dim pAnimExt As IAnimationExtension
    Set pAnimExt = Application.FindExtensionByCLSID(pUID)
    
    'Get animation environment from the animation extension
    Dim pAGAnimEnv As IAGAnimationEnvironment
    Set pAGAnimEnv = pAnimExt.AnimationEnvironment
    
    'Set the animation environment
    'Duration of animation
    pAGAnimEnv.AnimationDuration = 8
    
    'Specify the time interval when the animation will be played
    pAGAnimEnv.PutPlayInterval 3.5, 6.7
    
    'Set the interval play option to be true
    Dim bIntervalPlay As Boolean
    bIntervalPlay = pAGAnimEnv.IsIntervalPlay
    
    If bIntervalPlay = False Then
        pAGAnimEnv.IsIntervalPlay = True
    End If
    
    'Set the play mode to be "play once forward"
    pAGAnimEnv.PlayMode = esriAnimationPlayOnceForward
    
    'Using the AGAnimationUtils object to save the animation
    Dim pAGAnimUtils As IAGAnimationUtils
    Set pAGAnimUtils = New AGAnimationUtils
    
    pAGAnimUtils.SaveAnimationFile pAnimExt.AnimationTracks.AnimationObjectContainer, _
        "C:\temp\agAnimFile.ama", esriArcGISVersion92
    
End Sub