ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MapView Class / Animation Property
Example

In This Topic
    Animation Property (MapView)
    In This Topic
    Gets the animation for the view.
    Syntax
    public ViewAnimation Animation {get;}
    Public ReadOnly Property Animation As ViewAnimation
    Remarks
    This property will return null if the map's Map.Animation contains no keyframes. Similar to how the map defines the layers that make up the map, the map defines the animation and the keyframes for all views of the map. However, it is possible to have multiple views of a map set to different times in the animation. This property returns an object can be used to set the current time or frame, step to the next or previous keyframe, or play and stop the animation.
    Example
    Interpolate Camera
    {
      //Return the collection representing the camera for each frame in animation.
      await QueuedTask.Run(() =>
      {
        var animation = mapView.Map.Animation;
    
        var cameras = new List<Camera>();
        //We will use ticks here rather than milliseconds to get the highest precision possible.
        var ticksPerFrame = Convert.ToInt64(animation.Duration.Ticks / (animation.NumberOfFrames - 1));
        for (int i = 0; i < animation.NumberOfFrames; i++)
        {
          var time = TimeSpan.FromTicks(i * ticksPerFrame);
          //Because of rounding for ticks the last calculated time may be greater than the duration.
          if (time > animation.Duration)
          {
            time = animation.Duration;
          }
    
          cameras.Add(mapView.Animation.GetCameraAtTime(time));
        }
        // Use cameras
      });
    }
    Interpolate Time
    {
      //Return the collection representing the map time for each frame in animation.
      await QueuedTask.Run(() =>
      {
        var animation = mapView.Map.Animation;
    
        var timeRanges = new List<TimeRange>();
        //We will use ticks here rather than milliseconds to get the highest precision possible.
        var ticksPerFrame = Convert.ToInt64(animation.Duration.Ticks / (animation.NumberOfFrames - 1));
        for (int i = 0; i < animation.NumberOfFrames; i++)
        {
          var time = TimeSpan.FromTicks(i * ticksPerFrame);
          //Because of rounding for ticks the last calculated time may be greater than the duration.
          if (time > animation.Duration)
          {
            time = animation.Duration;
          }
    
          timeRanges.Add(mapView.Animation.GetCurrentTimeAtTime(time));
        }
        // Use timeRanges;
      });
    }
    Interpolate Range
    {
      //Return the collection representing the map time for each frame in animation.
      await QueuedTask.Run(() =>
      {
        var animation = mapView.Map.Animation;
    
        var ranges = new List<ArcGIS.Desktop.Mapping.Range>();
        //We will use ticks here rather than milliseconds to get the highest precision possible.
        var ticksPerFrame = Convert.ToInt64(animation.Duration.Ticks / (animation.NumberOfFrames - 1));
        for (int i = 0; i < animation.NumberOfFrames; i++)
        {
          var time = TimeSpan.FromTicks(i * ticksPerFrame);
          //Because of rounding for ticks the last calculated time may be greeting than the duration.
          if (time > animation.Duration)
          {
            time = animation.Duration;
          }
    
          ranges.Add(mapView.Animation.GetCurrentRangeAtTime(time));
        }
        // Use ranges
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also