- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have some iLogic written to place a view of an assembly in my drawing sheet to the scale I want. Is there a way to use a dialog box to select the assembly file I want to use rather than specify the full path in the code?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is the code.
Dim oPartDoc As AssemblyDocument oPartDoc = ThisApplication.Documents.Open("C:\Users\jishee\Documents\Work\Inventor_modeling\Dimensioning_Test\U001_Assembly.iam", False) Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawingDoc.Sheets.Item(1) Dim oPoint1 As Point2d oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(4.5#, 6#) Dim oView1 As DrawingView oView1 = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, 0.03125#, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle) ActiveSheet.View(oView1.Name).SetCenter(4.5, 6) Call oPartDoc.Close(True)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I added i filebrowser to select iam file to your code. Is this what you're looking for? ![]()
Dim oDlg As Inventor.FileDialog ThisApplication.CreateFileDialog(oDlg) oDlg.Filter = "Inventor Assembly Files (*.iam)|*.iam" oDlg.ShowOpen() ' to open files If oDlg.FileName = "" Then Exit Sub Dim oPartDoc As AssemblyDocument oPartDoc = ThisApplication.Documents.Open(oDlg.FileName, False) Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawingDoc.Sheets.Item(1) Dim oPoint1 As Point2d oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(4.5#, 6#) Dim oView1 As DrawingView oView1 = oSheet.DrawingViews.AddBaseView(oPartDoc, oPoint1, 0.03125#, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle) ActiveSheet.View(oView1.Name).SetCenter(4.5, 6) Call oPartDoc.Close(True)
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Here is an example if you want to be able to select ipt and ipn aswell.
Also in this example i added code so that if the file is already open in inventor, it doesnt close it when the rule is done.
If it isn't already open however, the file gets closed like in the previous code.
Dim oDlg As Inventor.FileDialog ThisApplication.CreateFileDialog(oDlg) With oDlg .Filter = "Assembly File (*.iam)|*.iam" _ & "|Part File (*.ipt)|*.ipt" _ & "|Presentation File (*.ipn)|*.ipn" .FilterIndex = 1 .InitialDirectory = ThisApplication.DesignProjectManager.ActiveDesignProject.WorkspacePath End With 'oDlg.Filter = "Inventor Assembly Files (*.iam)|*.iam" oDlg.ShowOpen() ' to open files If oDlg.FileName = "" Then Exit Sub Dim oDoc As Document Dim CloseWhenDone As Boolean = False Try oDoc = ThisApplication.Documents.ItemByName(oDlg.FileName) 'Get the document if it's already open. Catch oDoc = ThisApplication.Documents.Open(oDlg.FileName, False) CloseWhenDone = True 'If document wasn't already open, close it again after view is placed. End Try Dim oDrawingDoc As DrawingDocument oDrawingDoc = ThisApplication.ActiveDocument Dim oSheet As Sheet oSheet = oDrawingDoc.Sheets.Item(1) Dim oPoint1 As Point2d oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(4.5#, 6#) Dim oView1 As DrawingView oView1 = oSheet.DrawingViews.AddBaseView(oDoc, oPoint1, 0.03125#, kFrontViewOrientation, kHiddenLineRemovedDrawingViewStyle) ActiveSheet.View(oView1.Name).SetCenter(4.5, 6) If CloseWhenDone Then oDoc.Close(True)
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website