This document is archived and information here might be outdated.  Recommended version.


Navigate Scene to Bookmark3D Snippet (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference

Navigate Scene to Bookmark3D Snippet

Re-orient the visual perspective of a Scene to a specified BookMark3D.

[C#]
/// <summary>
/// Re-orient the visual perspective of a Scene to a specified BookMark3D. 
/// </summary>
/// <param name="sceneBookmarks">An ISceneBookmarks interface, that is a collection of bookmarks.</param>
/// <param name="bookmarkName">A System.String that is the name a particular BookMark3D in the ISceneBooksmarks collecton.</param>
/// <param name="sceneViewer">An ISceneViewer interface.</param>
/// <remarks>Only if the named Bookmark3D is found in the collection of ISceneBookmarks is the visual perspective of the Scene changed. 
/// Note: This snippet code is only for bookmarks created in the global navigation mode. 
/// It will not work with bookmarks created in surface navigation mode.</remarks>
public void NavigateSceneToBookmark3D(ESRI.ArcGIS.Analyst3D.ISceneBookmarks sceneBookmarks, System.String bookmarkName, ESRI.ArcGIS.Analyst3D.ISceneViewer sceneViewer)
{

  //Get a bookmark corresponding to list and apply it to the SceneViewer
  ESRI.ArcGIS.esriSystem.IArray array=sceneBookmarks.Bookmarks;
  System.Int32 bookmarkIndex=0;
  System.Int32 i=array.Count;
  for (bookmarkIndex=0; bookmarkIndex < i; bookmarkIndex++)
  {
    ESRI.ArcGIS.Analyst3D.IBookmark3D bookmark3D=(ESRI.ArcGIS.Analyst3D.IBookmark3D)array.get_Element(bookmarkIndex); // Explicit Cast
    if (bookmark3D.Name == bookmarkName)
    {

      //Switch to new bookmark location
      bookmark3D.Apply(sceneViewer, false, 0);

      return;

    }
  }

}
[Visual Basic .NET]
''' <summary>
''' Re-orient the visual perspective of a Scene to a specified BookMark3D. 
''' </summary>
''' <param name="sceneBookmarks">An ISceneBookmarks interface, that is a collection of bookmarks.</param>
''' <param name="bookmarkName">A System.String that is the name a particular BookMark3D in the ISceneBooksmarks collecton.</param>
''' <param name="sceneViewer">An ISceneViewer interface.</param>
''' <remarks>Only if the named Bookmark3D is found in the collection of ISceneBookmarks is the visual perspective of the Scene changed. 
''' Note: This snippet code is only for bookmarks created in the global navigation mode. 
''' It will not work with bookmarks created in surface navigation mode.</remarks>
Public Sub NavigateSceneToBookmark3D(ByVal sceneBookmarks As ESRI.ArcGIS.Analyst3D.ISceneBookmarks, ByVal bookmarkName As System.String, ByVal sceneViewer As ESRI.ArcGIS.Analyst3D.ISceneViewer)

  'Get a bookmark corresponding to list and apply it to the SceneViewer
  Dim array As ESRI.ArcGIS.esriSystem.IArray=sceneBookmarks.Bookmarks
  Dim bookmarkIndex As System.Int32
  For bookmarkIndex=0 To array.Count - 1
    Dim bookmark3D As ESRI.ArcGIS.Analyst3D.IBookmark3D=CType(array.Element(bookmarkIndex), ESRI.ArcGIS.Analyst3D.IBookmark3D) 'Explicit Cast
    If bookmark3D.Name=bookmarkName Then

      'Switch to new bookmark location
      bookmark3D.Apply(sceneViewer, False, 0)

      Exit Sub

    End If
  Next

End Sub

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.3DAnalyst
  • ESRI.ArcGIS.Animation
  • ESRI.ArcGIS.System