- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
is it possible to make a liogic code , se if the model that are use in the drawing is a part(.ipt) or an assambly(.iam) ?
and how do i do it
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I think you are looking for this code. I briefly tested it and it seems to work.
ThisDoc.Document.ReferencedDocuments(1).DocumentType
12290 is a Part
12291 is an Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, this ilogic rule is an example. Look on sheet 1, the first view, and look for the model of the view and if it is assembly, it will return a dialogue box with assembly, and if it is part it will return a message box with part.
This if you have the drawing file open
Dim oDoc As DrawingDocument = ThisDoc.Document Dim oView As DrawingView oView = oDoc.Sheets(1).DrawingViews.Item(1) oModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument If oModelDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then MessageBox.Show("Assembly") If oModelDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then MessageBox.Show("Part")
If you want to see if the view in assembly or part in a file that is not open you could use something like this.
Dim oFileDlg As Inventor.FileDialog = Nothing InventorVb.Application.CreateFileDialog(oFileDlg) oFileDlg.Filter = "Autodesk Inventor Drawing Files (*.idw)|*.idw" oFileDlg.InitialDirectory = ThisDoc.Path oFileDlg.CancelError = True On Error Resume Next oFileDlg.ShowOpen() If Err.Number <> 0 Then MessageBox.Show("File not chosen.", "Dialog Cancellation") ElseIf oFileDlg.FileName <> "" Then selectedfile = oFileDlg.FileName MessageBox.Show("File " & selectedfile & " was selected.", "Dialog Selection Made") End If Dim oDoc As DrawingDocument = ThisApplication.Documents.Open(selectedfile, False) Dim oView As DrawingView oView = oDoc.Sheets(1).DrawingViews.Item(1) oModelDoc = oView.ReferencedDocumentDescriptor.ReferencedDocument If oModelDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then MessageBox.Show("Assembly") If oModelDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject Then MessageBox.Show("Part") oDoc.Close
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report