Q:
I want to create a base drawing view with my own camera parameter. How to get the camera object and set its parameters to use with the "AddBaseView" method?
A:
The following VB.Net code sample illustrates the use of the Camera parameter with the "AddBaseView" method.
Note: The related Part or Assembly document has to be opened in Visible mode in order to retrieve the "Application.ActiveView.Camera" object.
The "ViewOrientation" parameter has to be "kArbitraryViewOrientation" in order to use a custom camera object.
Sub CreateBaseViewWithCamera(ByVal app As Inventor.Application)
'Open the part to insert in the drawing (Visible mode is required).
Dim oPartDoc As PartDocument =
app.Documents.Open("C:\Temp\Part1.ipt", True)
'Get Camera object
Dim oCamera As Camera = app.ActiveView.Camera
'Set your Camera parameters
oCamera.Eye = app.TransientGeometry.CreatePoint(0, 10, 10)
oCamera.Target = app.TransientGeometry.CreatePoint(0, 0, 0)
oCamera.UpVector = app.TransientGeometry.CreateUnitVector(0, 1, 0)
'Open the Drawing doc
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = app.Documents.Open(
"C:\Temp\Drawing1.idw", True)
Dim oSheet As Sheet
oSheet = oDrawingDoc.Sheets.Item(1)
'Position base view in middle of the sheet
Dim oViewPos As Point2d
oViewPos = app.TransientGeometry.CreatePoint2d(
oSheet.Width / 2, oSheet.Height / 2)
'Create view with parameters
Dim oBaseView As DrawingView
oBaseView = oSheet.DrawingViews.AddBaseView(
oPartDoc,
oViewPos,
1,
ViewOrientationTypeEnum.kArbitraryViewOrientation,
DrawingViewStyleEnum.kHiddenLineDrawingViewStyle,
"BaseView1",
oCamera)
'Close the part doc
oPartDoc.Close()
End Sub