So as part of run-time error avoidance, I am checking whether an object is a camera before setting it as the active camera:
Sub set_active_camera(ByRef name As String)
Dim obj As xpBaseObject = Me.get_object(name)
If Not IsNothing(obj) Then
If String.Equals(obj.TypeName, xpTypes.xpt_PerspCam) Or String.Equals(obj.TypeName, xpTypes.xpt_OrthoCam) Then
scene.SetActiveCamera(obj)
Else
show_error(String.Format("{0} not a perspective or orthographic camera ({1} vs {2})", name, obj.TypeName, xpTypes.xpt_PerspCam))
End If
Else
show_error("Camera " & name & " not found in scene.")
End If
End Sub
The problem is that the type name of the perspective camera object is "PerspCamera," but xpTypes defines "xpt_PerspCam" as "PerspCam."
I could just manually put in "PerspCamera" for the comparison, but that's not good programming style - so I'm wondering if these are defined in some other way I can generically test that will future proof code.