Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

find out if it is a Part Drawing og assambly Drawing using Ilogic

Darkforce_the_ilogic_guy
Advisor

find out if it is a Part Drawing og assambly Drawing using Ilogic

Darkforce_the_ilogic_guy
Advisor
Advisor

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 

0 Likes
Reply
Accepted solutions (2)
373 Views
4 Replies
Replies (4)

ianteneth
Advocate
Advocate
Accepted 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

 

 

 

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

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

Darkforce_the_ilogic_guy
Advisor
Advisor

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

 

 

0 Likes

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

0 Likes