Debug iLogic code

<?xml encoding=”UTF-8″>By Adam Nagy

Unfortunately, in iLogic you do not have the same features you get in case of VBA or Visual Studio projects. Stepping through the code, checking variable values, setting up breakpoints are all missing from the iLogic environment.

If the iLogic functionality is not enough and you also need to access the underlying Inventor API, then I think the easiest way is to test things out in VBA. There you can also get familiar with the object model by examining the properties of existing objects: http://adndevblog.typepad.com/manufacturing/2013/10/discover-object-model.html

One way to debug iLogic code could be using Trace calls, which can write out information about where the code is at a given moment and what the values of certain variables are. This was mentioned on the forum: https://forums.autodesk.com/t5/Inventor-General-Discussion/iLogic-Developing-and-debugging/m-p/2850580  

I used one of my test documents (Download ILogicTestDebug) and added a couple more rules to it so that I can see which rule is called after which other rule, etc. Just placed Trace calls like these inside the rules:

Trace.WriteLine("iLogic: 'Update' rule start")
Trace.WriteLine("iLogic: 'Width' = " + currentWidth.ToString())

Note: you might need to add Imports System.Diagnostics at the beginning of the rule 

Once I downloaded the DebugView application I could see all my messages in there, along with messages coming from other applications:

Debugview

 


Comments

2 responses to “Debug iLogic code”

  1. Epic! This is an awesome tip! I’ve been doing it with MessageBox for years but it’s not exactly neat and tidy. This is a far better solution. More recently, for more complicated stuff I’ve been writing dlls for the logic and importing them into the iLogic rule and then debugging the dll with visual studio, but that’s a long way of doing it and kinda defeats the purpose of iLogic’s simplicity. Thanks for sharing!

  2. Luke Davenport Avatar
    Luke Davenport

    Great tip Adam. Thank you!

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading