With this code you can create an image of the reference document of the view (in my example accessing through the item).
This ilogic is executed from the drawing file.
You must specify well the path where the image will be saved, in micaso the disk "E".
I hope it is useful for you. regards
oPath = "E:\"
Dim oDoc As DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Dim oView As DrawingView = oSheet.DrawingViews.Item(1)
oViewModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument
Dim oViewModelDocName As String = Left(oViewModelDoc.DisplayName, (InStrRev(oViewModelDoc.DisplayName, ".", - 1, vbTextCompare) - 1))
Dim m_Camera As Inventor.Camera
m_Camera = ThisServer.TransientObjects.CreateCamera()
If oViewModelDoc.DocumentType = kPartDocumentObject Then
m_Camera.SceneObject = DirectCast(oViewModelDoc, PartDocument).ComponentDefinition
Else
m_Camera.SceneObject = DirectCast(oViewModelDoc, AssemblyDocument).ComponentDefinition
End If
m_Camera.Perspective = False
Dim m_TO As Inventor.TransientObjects
m_TO = ThisApplication.TransientObjects
m_Camera.ViewOrientationType = Inventor.ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
m_Camera.Fit
m_Camera.ApplyWithoutTransition
ThisApplication.DisplayOptions.NewWindowDisplayMode = DisplayModeEnum.kShadedWithEdgesRendering
ThisApplication.DisplayOptions.Show3DIndicator = False
Dim TumbFilename As String = oPath & oViewModelDocName & ".bmp"
m_Camera.SaveAsBitmap(TumbFilename, 800, 600, m_TO.CreateColor(255,255,255))
Please accept as solution and give likes if applicable.
I am attaching my Upwork profile for specific queries.
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn