Get Scene Layers


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

How to use:
  1. Paste the code into ArcScene's VB Editor.
  2. Run the function from a calling procedure which sets the return value of GetSceneLayers to an IEnumLayer interface variable.
Public Function GetSceneLayers() As IEnumLayer
  Dim pCurrentApp As IApplication
  Dim pBasicMap As IBasicMap
  Set pCurrentApp = Application
  If TypeOf pCurrentApp Is ISxApplication Then
    Dim pSxDoc As ISxDocument
    Set pSxDoc = pCurrentApp.Document
    Set pBasicMap = pSxDoc.Scene
    Exit Function
  End If
  If pBasicMap.layerCount = 0 Then
    Set GetSceneLayers = Nothing
    Set GetSceneLayers = pBasicMap.Layers
  End If
End Function