This sample shows you how to create a Flyby-From-Path animation in ArcMap. It requires a line feature layer as the flyby path to work.
How to use
- Open ArcMap and add a feature or raster layer to the ArcMap TOC;
- Add a line feature layer to the TOC as the flyby path;
- Organize the layers in the TOC, so that the line feature layer is the second layer;
- Copy and paste the following code into the VB editor in ArcMap;
- Make sure that "ESRI Animation Object Library" and "ESRI AnimationUI Object Library" are checked in the References dialog box of the VBA project;
- Run the macro "Create_FlybyFromPath_Animation";
- Click the Animation dropdown on the Animation toolbar and click Animation Manager. In the Animation Manager dialog box, click the Tracks tab to verify that a new track from path has been created.
Public Sub Create_FlybyFromPath_Animation()
'Find the animation extension
Dim pUID As New UID
pUID.Value = "esriAnimation.AnimationExtension"
Dim pAnimExt As IAnimationExtension
Set pAnimExt = Application.FindExtensionByCLSID(pUID)
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
Dim pMap As IMap
Set pMap = pMxDoc.Maps.Item(0)
'Get the line feature in the path layer
Dim pLayer As ILayer
Set pLayer = pMap.Layer(1)
Dim pFClass As IFeatureClass
Dim pFLayer As IFeatureLayer
Set pFLayer = pLayer
Set pFClass = pFLayer.FeatureClass
Dim pFeature As IFeature
Set pFeature = pFClass.GetFeature(0)
'Get the geometry of the line feature
Dim pGeom1 As IGeometry
Set pGeom1 = pFeature.Shape
'Create AGAnimationUtils and AGImportPathOptions objects
Dim pAGAnimUtils As IAGAnimationUtils
Set pAGAnimUtils = New AGAnimationUtils
Dim pAGImpOptions As IAGImportPathOptions
Set pAGImpOptions = New AGImportPathOptions
'Set properties for AGImportPathOptions
Set pAGImpOptions.AnimatedObject = pMap 'Animation object is the map
Set pAGImpOptions.AnimationType = New AnimationTypeMapView
Set pAGImpOptions.AnimationTracks = pAnimExt.AnimationTracks
pAGImpOptions.PathGeometry = pGeom1
Set pAGImpOptions.AnimationEnvironment = pAnimExt.AnimationEnvironment
Dim pBasicMap As IBasicMap
Set pBasicMap = pMap 'QI
Set pAGImpOptions.BasicMap = pBasicMap
Dim pAnimContainer As IAGAnimationContainer
Set pAnimContainer = pAnimExt.AnimationTracks.AnimationObjectContainer
'Call "CreateFlybyFromPath"
pAGAnimUtils.CreateFlybyFromPath pAnimContainer, pAGImpOptions
End Sub