ArcObjects Library Reference

Get Globe from Application Snippet

Gets the IGlobe interface from IApplication.

[C#]

///<summary>Gets the IGlobe interface from IApplication.</summary>
///  
///<param name="application">An IApplication interface.</param>
///   
///<remarks>An IGlobe interface.</remarks>
public ESRI.ArcGIS.GlobeCore.IGlobe GetGlobeFromApplication(ESRI.ArcGIS.Framework.IApplication application)
{
  if(application == null)
  {
    return null;
  }
  ESRI.ArcGIS.ArcGlobe.IGMxDocument gmxDocument = application.Document as ESRI.ArcGIS.ArcGlobe.IGMxDocument; // Dynamic Cast
  ESRI.ArcGIS.Analyst3D.IScene scene = gmxDocument.Scene;
  ESRI.ArcGIS.GlobeCore.IGlobe globe = scene as ESRI.ArcGIS.GlobeCore.IGlobe; // Dynamic Cast

  return globe;
}
[Visual Basic .NET]

'''<summary>Gets the IGlobe interface from IApplication.</summary>
'''  
'''<param name="application">An IApplication interface.</param>
'''   
'''<remarks>An IGlobe interface.</remarks>
Public Function GetGlobeFromApplication(ByVal application As ESRI.ArcGIS.Framework.IApplication) As ESRI.ArcGIS.GlobeCore.IGlobe

  If application Is Nothing Then
    Return Nothing
  End If

  Dim gmxDocument As ESRI.ArcGIS.ArcGlobe.IGMxDocument = TryCast(application.Document, ESRI.ArcGIS.ArcGlobe.IGMxDocument) ' Dynamic Cast
  Dim scene As ESRI.ArcGIS.Analyst3D.IScene = gmxDocument.Scene
  Dim globe As ESRI.ArcGIS.GlobeCore.IGlobe = TryCast(scene, ESRI.ArcGIS.GlobeCore.IGlobe) ' Dynamic Cast

  Return globe

End Function


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