- 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.
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.
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
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
Sergio Daniel Suarez
Mechanical Designer
| Upwork Profile | LinkedIn
thanks for your answer that was just what I needed. think that just save me more then an hour of saving times on a large drawing, that I was not getting anything form
thanks for the answer. I did end up using the other code. but it always nice to get some new input in how you might do it