By Wayne Brill
If you are using Fit method of a view before calling the SaveAsBitmap method of the view you may have noticed that the Fit does not occur until the code has exited and so you do not get the image you expect. To resolve this you can use the Camera object.
VBA Example:
Sub cameraAndSaveAsBitmap()
If ThisApplication.Documents.count = 0 _
Then Exit Sub
Dim oView As view
Set oView = ThisApplication.ActiveView
Dim oCamera As Camera
Set oCamera = oView.Camera
oCamera.Fit
oCamera.Apply
' OR oCamera.ApplyWithoutTransition
Call oView.SaveAsBitmap _
("C:\temp\assembly.bmp", 400, 400)
End Sub
VB.NET
Public Class Form1
Dim m_inventorApp As Inventor.Application _
= Nothing
Private Sub Button1_Click(ByVal sender As _
System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
' Get an active instance of Inventor
Try
m_inventorApp = System.Runtime. _
InteropServices.Marshal. _
GetActiveObject("Inventor.Application")
Catch 'Inventor not started
System.Windows.Forms.MessageBox. _
Show("Start an Inventor session")
Exit Sub
End Try
'Call the Sub
cameraAndSaveAsBitmap()
End Sub
Sub cameraAndSaveAsBitmap()
If m_inventorApp.Documents.Count = 0 _
Then Exit Sub
Dim oView As view
oView = m_inventorApp.ActiveView
Dim oCamera As Camera
oCamera = oView.Camera
oCamera.Fit()
oCamera.Apply()
' OR oCamera.ApplyWithoutTransition
Call oView.SaveAsBitmap _
("C:\temp\assembly.bmp", 400, 400)
End Sub
End Class