Issue
How to access the views represented by the document windows open in an Inventor session?
An Inventor session can have one or more documents open. Each of the documents will be displayed in its own window. Also, in addition, you could have one or more views (e.g. top view, right view etc.) of a document being displayed in separate windows. So, each window displays a view of a particular document with the possibility that the source document could be the same for the windows (i.e. the windows are displaying different views of the same document).
The API allows access to these views of the same or different documents that are being displayed in separate windows. From the Application object you could get the ActiveView object (represents the currently active view (might be one of many) of a document). The ActiveView object corresponds to the active window in the Inventor session. The ActiveView object in turn supports the Camera object that helps you set the new orientation using the ViewOrientationType property. Also, if one or more views of a particular document are being displayed in separate windows, they can also be accessed using the Views object obtained from the Document object.
The following is a VBA sample to access and change view orientation:
Public Sub GetViews()
'access only the currently active view of a document
Dim oActiveView As View
Set oActiveView = ThisApplication.ActiveView
Dim oCamera As Camera
Set oCamera = oActiveView.Camera
oCamera.ViewOrientationType = kIsoBottomRightViewOrientation
oCamera.Apply
'if you have multiple windows(views) of a document open,
'you can access all of them
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
Dim oViews As Views
Set oViews = oDoc.Views
Dim oView As View
For Each oView In oViews
Set oCamera = oView.Camera
Next
End Sub
The equivalent C# code:
private void GetViews()
{
// access only the currently active view of a document
Inventor.View oActiveView = oApp.ActiveView;
Camera oCamera = oActiveView.Camera;
oCamera.ViewOrientationType =
ViewOrientationTypeEnum.kIsoBottomRightViewOrientation;
oCamera.Apply();
// if you have multiple windows(views) of a document open,
// you can access all of them
Inventor.Document oDoc = oApp.ActiveDocument;
Views oViews = oDoc.Views;
foreach (Inventor.View oView in oViews)
{
oCamera = oView.Camera;
}
}