Test is file is iPart or iAssembly

Test is file is iPart or iAssembly

Rob67ert
Collaborator Collaborator
930 Views
3 Replies
Message 1 of 4

Test is file is iPart or iAssembly

Rob67ert
Collaborator
Collaborator

Hi,

To test is a file is an iPart I use:

SyntaxEditor Code Snippet

Dim partDoc As PartDocument = ThisApplication.ActiveDocument
If partDoc.ComponentDefinition.IsiPartFactory Or partDoc.ComponentDefinition.IsiPartMember Then
    MessageBox.Show("This IS an iPart", "Title")
    Return 'do nothing
Else
MessageBox.Show("This is NOT an iPart", "Title")
End If

But what do I need to check if it is an iPart or an iAssembly?

 

I like to run some iLogic on my files, but not on the iPart or iAssembly files.

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Accepted solutions (1)
931 Views
3 Replies
Replies (3)
Message 2 of 4

TONELLAL
Collaborator
Collaborator
Hi,
Try this :

Dim
partDoc As Document = ThisApplication.ActiveDocument

If oDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
'...Assembly document

If oDoc.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
'...part document
 

 

Alain 

0 Likes
Message 3 of 4

Rob67ert
Collaborator
Collaborator
This wil not work.
It will also see the iPart factory part as a part and the iAssembly factory as a assembly.

Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes
Message 4 of 4

Rob67ert
Collaborator
Collaborator
Accepted solution

Found it:

SyntaxEditor Code Snippet

'Part file
If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject And oDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
    If oDoc.ComponentDefinition.IsiPartFactory Or oDoc.ComponentDefinition.IsiPartMember Then
        MessageBox.Show("This is a iPart", "iPart")
        Return
    End If
    MessageBox.Show("This ia a Part", "Part")

'Assembly file
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
    If oDoc.ComponentDefinition.IsiAssemblyFactory Or oDoc.ComponentDefinition.IsiAssemblyMember Then
        MessageBox.Show("Dit is een iAssembly", "Title")
        Return
    End If
    MessageBox.Show("Dit is een Assembly", "Title")
End If
Robert

If you find this reply helpful ? It would be nice if you use the Accept as Solution or Kudos button below.
0 Likes