11-20-2019
07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
11-20-2019
07:03 AM
Hi, this is an example in ilogic.
It can be executed in a part or assembly file.
"oSep" is the separation between views.
It is an example, a more complex code can be made as more functions are added, but it can serve as a starting point for learning.
Dim oDoc As Document = ThisDoc.Document ' Part Document or Assembly Document Dim oSep As Double = 2 '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 Err.Number <> 0 Then Exit Sub ElseIf oFileDlg.FileName <> "" Then MasterFile = oFileDlg.FileName End If Dim oDrawingDoc As DrawingDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject,templateFile,True) oDrawingDoc.Activate() Dim oSheet As Sheet = oDrawingDoc.Sheets.Item(1) Dim oCentralPoint As Point2d = ThisApplication.TransientGeometry.CreatePoint2d(oSheet.Width/2, oSheet.Height/2) Dim oView As DrawingView oView = oSheet.DrawingViews.AddBaseView(oDoc,oCentralPoint, 1, ViewOrientationTypeEnum.kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle) 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) 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
I hope this can be useful. Cheers!
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