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

Can't get oDoc.DocumentType to work today.

I'm working on rule and it was working just fine for parts and assemblies, but now that I added drawings to it, it no longer works for parts or assemblies. I then found Cutis Waguespack's example, which I get the same issue with.  When I run the following code on a part or assembly.  I get the error. "ThisDrawing: This document "testfile.ipt" is not a drawing."  I know its not a drawing.  Anyone know why this is behaving this way?

 

 

Dim oDoc As Document
oDoc = ThisDoc.Document

If oDoc.DocumentType = Inventor.DocumentTypeEnum.kPartDocumentObject  Then
            If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
            MessageBox.Show("You have a sketch active in a part file.", "iLogic")
            Else
            MessageBox.Show("This is a part file.", "iLogic")
            End If
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
            If TypeOf ThisApplication.ActiveEditObject Is Sketch Then
            MessageBox.Show("You have a sketch active in an assembly file.", "iLogic")
            Else
            MessageBox.Show("This is an assembly file.", "iLogic")
            End If
Else If oDoc.DocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
            drwquestion = MessageBox.Show("This is a drawing file, Do you want to open the file?","Ilogic", MessageBoxButtons.YesNo,MessageBoxIcon.Question)
    'set condition based on answer
    If drwquestion = vbYes Then
        'Try
        modelFullFileName = ThisDrawing.ModelDocument.FullFileName
        'Catch
        'End Try
        ThisApplication.Documents.Open(modelFullFileName, True)
        Else If drwquestion = vbNo Then
    End If
    Return
End If