iLogic and ipn files?

iLogic and ipn files?

Anonymous
Not applicable
1,142 Views
2 Replies
Message 1 of 3

iLogic and ipn files?

Anonymous
Not applicable

Backstory: I currently have some code out on our company network that all drafters/engineers use that will clear out the title block, insert their user name, today's date, and copy the iProperties Description field from the model to the drawing (along with a few other items that are irrelevant here).

 

Issue: This has been working for nearly a year flawlessly, until today. We noticed that if you place an IPN file into the drawing first, it will error out. I've tried several variations of getting the filename, however anytime I attempt to reference anything in the IPN file, i get an error. I've seen a few comments that iLogic doesn't play well with IPN files, could this be my issue?

 

Error as received:

 

Error in rule: Drafting New, in document: F0000099.idw

Object reference not set to an instance of an object.

 

My code is as follows:

 

SyntaxEditor Code Snippet

question = MessageBox.Show("Would you like to update drafter's information?", "Update?",MessageBoxButtons.YesNo,MessageBoxIcon.Question)



'set condition based on answer
    If question = vbYes Then
        If ActiveSheet.TitleBlock = "UEC - Wiring" Or ActiveSheet.TitleBlock = "UEC - DC Wiring" Then

            'Get iProperties information for Project -> Description
            TitleInput:
            Dim DwgDesc As String
            DwgDesc = InputBox("Please Enter Drawing Title", "Drawing Title")
            iProperties.Value("Project", "Description") = DwgDesc
            currentLength = Len(DwgDesc)
            If currentLength = 0 Then
            MessageBox.Show("Please Enter Valid Drawing Title")
            Goto TitleInput
            End If
            
            'Get username
            myName = ThisApplication.UserName
            
            
            iProperties.Value("Summary", "Author") = ""
            iProperties.Value("Project", "Designer") = ""
            iProperties.Value("Project", "Engineer") = ""
            iProperties.Value("Status", "Checked By") = ""
            iProperties.Value("Status", "Eng. Approved By") = ""
            iProperties.Value("Status", "Mfg. Approved By") = ""

            
            iProperties.Value("Summary", "Author") = myName
            iProperties.Value("Summary", "Comments") = "Original issue"
            
            iProperties.Value("Project", "Revision Number") = "A"
            iProperties.Value("Project", "Designer") = myName
            iProperties.Value("Project", "Creation Date") = Now
            
            iProperties.Value("Status", "Checked By") = myName
            iProperties.Value("Status", "Checked Date") = Now
            iProperties.Value("Status", "Eng. Approved Date") = Never
            iProperties.Value("Status", "Mfg. Approved Date") = Never


        Else
        
            'Define the open document
            Dim openDoc As Document
            openDoc = ThisDoc.Document
            'Look at the model file referenced in the open document
            Dim docFile As Document
            If ThisDoc.ModelDocument IsNot Nothing Then
                docFile = ThisDoc.ModelDocument
                'check file type 
                'format model file name                   
                Dim FNamePos As Long
                FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
                Dim docFName As String 
                docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
                iProperties.Value("Project", "Description") = iProperties.Value(docFName, "Project", "Description")
                
                'Get username
                myName = ThisApplication.UserName
                
                
            iProperties.Value("Summary", "Author") = ""
            iProperties.Value("Project", "Designer") = ""
            iProperties.Value("Project", "Engineer") = ""
            iProperties.Value("Status", "Checked By") = ""
            iProperties.Value("Status", "Eng. Approved By") = ""
            iProperties.Value("Status", "Mfg. Approved By") = ""
            
            iProperties.Value("Summary", "Author") = myName
            iProperties.Value("Summary", "Comments") = "Original issue"
            
            iProperties.Value("Project", "Revision Number") = "A"
            iProperties.Value("Project", "Designer") = myName
            iProperties.Value("Project", "Creation Date") = Now
            
            iProperties.Value("Status", "Checked By") = myName
            iProperties.Value("Status", "Checked Date") = Now
            iProperties.Value("Status", "Eng. Approved Date") = Never
            iProperties.Value("Status", "Mfg. Approved Date") = Never

            iProperties.Value(docFName, "Project", "Revision Number") = "A"
            iProperties.Value(docFName, "Project", "Designer") = myName
            iProperties.Value(docFName, "Project", "Engineer") = ""


            Else
                MessageBox.Show("This drawing has no model reference. Please place model reference and try again.", "Missing model reference", MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1)
            Return
            End If
            
        End If
MessageBox.Show("Drawing has been updated with your name and today's date.", "Drawing Updated", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1)
        
        InventorVb.DocumentUpdate()
        
    Else If question = vbNo Then
    
q = MessageBox.Show("Drawing information has not been updated.", "Not Updated", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)


    End If

 

Any ideas on how to make IPN files play with iLogic?

0 Likes
1,143 Views
2 Replies
Replies (2)
Message 2 of 3

r_lehmann79
Advocate
Advocate

no answers ?!?

-------------------------------------------
Inventor 2016 + Vault Basic 2016
0 Likes
Message 3 of 3

MegaJerk
Collaborator
Collaborator

I'm not running into any of the same problems. 

I created a new drawing, threw an IPN onto the first sheet, and ran the code without error. 

Perhaps you could make some dummy files / rules that result in problems.

I would also suggest the tedious task of debugging your code by way of message boxes. Which parts (messagebox.show) are you able to get to before you run into the error you're reaching? 




If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
0 Likes