Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
mcgyvr
in reply to: Anonymous

Well.. you have some options..

Do you want to prompt for the file name?

Do you want the file name to just be the models file name + png?

 

You really can't do a variable as there isn't a method to store the "last known state" that I know of short of exporting to a file and reading that file over each time but thats a bit silly for such a simple task..

 

Try this..

 

Option Explicit On
Dim m_Doc As Inventor.Document
m_Doc = ThisDoc.Document

If m_Doc.DocumentType <> kAssemblyDocumentObject _
   And m_Doc.DocumentType <> kPartDocumentObject Then
   MessageBox.Show("File is not a model.", "iLogic")
   Return 'exit rule
End If

Dim m_Camera As Inventor.Camera
m_Camera = ThisServer.TransientObjects.CreateCamera()
If m_Doc.DocumentType = kPartDocumentObject Then
  m_Camera.SceneObject = DirectCast(m_Doc, PartDocument).ComponentDefinition
Else
  m_Camera.SceneObject = DirectCast(m_Doc, AssemblyDocument).ComponentDefinition
End If
'm_Camera.Perspective = True

Dim m_TO As Inventor.TransientObjects
m_TO = ThisApplication.TransientObjects

Dim oFileName As String = ThisDoc.FileName(False)

m_Camera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
m_Camera.Fit
m_Camera.ApplyWithoutTransition
 
Dim m_PrevMode As DisplayModeEnum
Dim m_Disp3D As Boolean
Dim myimagename As String m_Disp3D = ThisApplication.DisplayOptions.Show3DIndicator m_PrevMode = ThisApplication.DisplayOptions.NewWindowDisplayMode ThisApplication.DisplayOptions.NewWindowDisplayMode = DisplayModeEnum.kShadedWithEdgesRendering ThisApplication.DisplayOptions.Show3DIndicator = False Try myimagename = InputBox("Enter a file name", "Image File Name", "Name01.png") m_Camera.SaveAsBitmap("C:\Export\" & myimagename, 2970, 2100, m_TO.CreateColor(255,255,255)) Finally ThisApplication.DisplayOptions.NewWindowDisplayMode = m_PrevMode ThisApplication.DisplayOptions.Show3DIndicator = m_Disp3D End Try

 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269