Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I want to automatically add the screenshot taken in the code I wrote below to the technical drawing. Can you help me?
Sub Main()
Dim oPart As PartDocument
oPart = ThisApplication.ActiveDocument
Dim o3dActiveView As Inventor.View
o3dActiveView = ThisApplication.ActiveView
Dim oPartNumber As String
oPartNumber = oPart.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value
Dim o3DCamera As Camera
o3DCamera = o3dActiveView.Camera
o3DCamera.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopLeftViewOrientation
o3DCamera.Apply()
o3dActiveView.Fit()
Dim oFolder As String
oFolder = "C:\Users\byzkc\Desktop\iLogic Deneme Assembly"
Dim oFileName As String
oFileName = oFolder & oPartNumber & ".jpeg"
o3dActiveView.SaveAsBitmap(oFileName & ".jpg", 1300, 1300)
Dim oDrawingDoc As DrawingDocument
oDrawingDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, "C:\Users\byzkc\Desktop\iLogic Deneme Assembly\de.idw", True)
oDrawingDoc.Activate()
Dim oSheet As Sheet
oSheet = oDrawingDoc.Sheets.Item(1)
Dim x1 As Double = 10.2
Dim y1 As Double = 16.2
Dim x2 As Double = 20.2
Dim y2 As Double = 22.2
Dim width As Double = x2 - x1
Dim height As Double = y2 - y1
Dim centerX As Double = x1 + (width / 2)
Dim centerY As Double = y1 + (height / 2)
Dim oPoint1 As Point2d
oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(centerX, centerY)
Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oPart, oPoint1, 1.1, ViewOrientationTypeEnum.kIsoTopRightViewOrientation, DrawingViewStyleEnum.kShadedDrawingViewStyle)
Dim scaleFactor As Double = Math.Min((width / oView.Width), (height / oView.Height))
oView.Scale = scaleFactor
MsgBox(oPartNumber & " Ekran Görüntüsü Alındı")
End Sub
Solved! Go to Solution.