How to get the globe's layers


Placed inside ArcGlobe's VBA, this routine will return an IEnumLayer interface containing pointers to all the layers in the globe.

How to use

  1. Paste the code into ArcGlobe's VB Editor.
  2. Run the function from a calling procedure which sets the return value of GetGlobeLayers to an IEnumLayerinterface variable.
[VBA]
Public Function GetGlobeLayers() As IEnumLayer
    Dim pCurrentApp As IApplication
    Dim pBasicMap As IBasicMap
    
    Set pCurrentApp = Application
    
    If TypeOf pCurrentApp Is IGMxApplication Then
        Dim pGMxDoc As IGMxDocument
        Set pGMxDoc = pCurrentApp.Document
        Set pBasicMap = pGMxDoc.Scene
    Else
        Exit Function
    End If
    
    If pBasicMap.layerCount = 0 Then
        Set GetGlobeLayers = Nothing
    Else
        Set GetGlobeLayers = pBasicMap.Layers
    End If
    
End Function