Why does Camera.ViewOrientationType always return kArbitraryViewOrientation?

Issue

It does not matter what I set my camera's ViewOrientationType to, it always returns kArbitraryViewOrientation. Why is that?

Solution

The enums that specify a particular camera angle can be used to set the camera, but the return value of the camera will always return arbitrary. It's a bit difficult to say exactly what one of these specified views is precisely. When you set a view to one of these defined views it sets the position of the camera, the up vector, and fits the view. Because the camera reacts to the model size these defined views are always different. It's possible that we could just use the eye direction and up vector to determine if it matches one of these predefined views, but that may not be enough for someone else. We've chosen to instead always return arbitrary and let the developer do the comparisons themselves on the camera since they know what's important to them.


Comments

3 responses to “Why does Camera.ViewOrientationType always return kArbitraryViewOrientation?”

  1. MaxU77 Avatar
    MaxU77

    Hi Gary,
    We need to set orientation of one model exactly as it in some other model.
    But we that exact problem.
    What would be your recommendation for such case?
    Thanks in advance.

  2. MaxU77 Avatar
    MaxU77

    In fact my question was asked a bit before our coder studied the question deep enough.
    Finally he have solved the problem somehow.

  3. Wayne Brill Avatar
    Wayne Brill

    Here is a VBA code example I used to test. It uses a calculation with the UpVector property of the Camera and the AngleTo method of the UnitVector.
    It is able to determine if the view was created using one of the default Iso Views or not. There is probably a better mathematical way to do this but it does show a way to determine if a view is an Iso view.
    Public Sub cameraTest()
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument
    Dim oCamera As Inventor.Camera
    Dim oCamVec As UnitVector
    Dim myUnitVector As UnitVector
    Set myUnitVector = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
    Dim AngleDegree As Double
    Dim myString As String
    myString = “”
    Dim oDrwView As DrawingView
    For Each oDrwView In oDrawDoc.ActiveSheet.DrawingViews
    Set oCamera = oDrwView.Camera
    Set oCamVec = oCamera.UpVector
    Set myUnitVector = ThisApplication.TransientGeometry.CreateUnitVector(0, 1, 0)
    Dim PI As Double
    PI = 3.14159265358979
    AngleDegree = oCamVec.AngleTo(myUnitVector) * 180 / PI
    If AngleDegree > 35 And AngleDegree < 36 Then
    myString = myString & oDrwView.Name & ” is an Iso View” & vbCr
    Else
    myString = myString & oDrwView.Name & ” is NOT an Iso View” & vbCr
    End If
    Next
    Call MsgBox(myString)
    End Sub

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading