How to get the scene's camera


This routine when called will return the ICamera interface of the current scene's scenegraph viewer.

How to use

  1. Paste the code into VBA
  2. Run the function from a calling procedure which sets the return value of GetSceneCamera to an ICamera interface variable.
[VBA]
Public Function GetSceneCamera() As ICamera
    ' Returns the ICamera interface of the current scene
    
    Dim pSG As ISceneGraph
    Dim pScene As IScene
    Dim pSxDoc As ISxDocument
    Dim pViewer As ISceneViewer
    
    Set pSxDoc = Application.Document
    Set pScene = pSxDoc.Scene
    
    Set pSG = pScene.SceneGraph
    
    Set pViewer = pSG.ActiveViewer
    Set GetSceneCamera = pViewer.Camera
    
End Function