Blog posts

Bio

by Clint Brown

Following on from my last blog post on Trouble Shooting Inventor iLogic Error Messages

I thought I would share some tips on capturing your errors in ilogic. In VB.Net and other software development code, programmers have a few tricks for error handling. Out of the box, iLogic does not have any error handling capability, so I wrote a bit of code to make this easier.

 

There is a little bit of code I sometimes use when writing code, or when working in parts or assemblies where there are several illogic rules that all need to fire in sequence. This code pops up a message box telling us that an error has occurred, although I usually comment out the message box, more interestingly, it writes out any errors to a text file called iLogicErrorLog.txt, which is automatically created in the C:\TEMP folder

The output looks like this:

15:31:58 -There is an Error in Rule2 - The File in question is: C:\Support\ilogic debug.ipt
15:32:55 -There is an Error in Rule2 - The File in question is: C:\Support\ilogic debug.ipt

The code runs within a Sub, all you need to do, is paste your rule between the dotted lines in the code below, and you now have some error handing in iLogic

As a test, you could create a new part file, create a new rule, and put something like this into the code to create an error (Most files would not have an Extrusion 1000, so this should error)

Feature.IsActive("Extrusion1000") = False

Once the error message has popped up, go have a look at C:\TEMP\iLogicErrorLog.txt

 

Here is the code:

Sub Main()

On Error Goto ClintsErrorTrapper:

xxx = "Rule 2" ' Put the name of this rule here

'-----YOUR CODE GOES BETWEEN THESE DOTTED LINES-------'

 

'-----YOUR CODE GOES BETWEEN THESE DOTTED LINES-------'

Exit Sub

ClintsErrorTrapper:

yyy = ThisDoc.PathAndFileName(True)

MessageBox.Show("An error was found in " & xxx, "Cadline Community")

oWrite = System.IO.File.appendtext("C:\TEMP\iLogicErrorLog.txt")

oWrite.WriteLine(TimeString & " -There is an Error in " & xxx & " - The File in question is: " & yyy)

oWrite.Close()

End Sub