In the case of the previous code, you first identify the active document
Dim oDoc As Document = ThisDoc.Document ' Part Document or Assembly Document
Now you define the separation between the views
Dim oSep As Double = 2
Now you need to open the dialog box to select a drawing template, look in the template path, look at the detail in red
'Create a drawing from the drawing template
Dim oFileDlg As Inventor.FileDialog = Nothing
ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Inventor Files (*.idw)|*.idw"
oFileDlg.DialogTitle = "Select Drawing Template"
oFileDlg.InitialDirectory = ThisApplication.FileOptions.TemplatesPath
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If there is an error or you do not select anything, leave the code without returning an error box
If Err.Number <> 0 Then
Exit Sub
ElseIf oFileDlg.FileName <> "" Then
MasterFile = oFileDlg.FileName
End If
Now you will create a new drawing file from the selected template
Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,templateFile,True)
Now activate the drawing
oDrawingDoc.Activate()
Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1)
Now take the center point of the sheet
Dim oCentralPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width/2, oSheet.Height/2)
Now place the base view at the center point of the sheet
Dim oView As DrawingView
oView = oSheet.DrawingViews.AddBaseView(oDoc,oCentralPoint, 1, ViewOrientationTypeEnum.kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
Create projected views in arbitrary locations
Dim V1Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y)
Dim V2Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - 10)
Dim V3Point2D As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + 10, oView.Center.Y - 10)
Dim oView1 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V1Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView2 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V2Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Dim oView3 As DrawingView = oSheet.DrawingViews.AddProjectedView(oView, V3Point2D, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)
Correct the positions of the views according to the separation entered and depending on the width and length of each view
oView1.Position= ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + oView.Width / 2 + oSep + oView1.Width / 2, oView1.Center.Y)
oView2.Position = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X, oView.Center.Y - oView.Height / 2 - oSep - oView2.Height / 2)
oView3.Position = ThisApplication.TransientGeometry.CreatePoint2d(oView.Center.X + oView.Width / 2 + oSep + oView3.Width / 2, _
oView.Center.Y - oView.Height / 2 - oSep - oView3.Height / 2)
oView3.ViewStyle = oView.ViewStyle
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