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