iLogic Debugging

iLogic Debugging

Anonymous
Not applicable
5,294 Views
10 Replies
Message 1 of 11

iLogic Debugging

Anonymous
Not applicable

Adding some debugging functionality would be very helpful.  I find myself having to add message boxes everywhere to find where my errors are.

5,295 Views
10 Replies
Replies (10)
Message 2 of 11

adam.nagy
Autodesk Support
Autodesk Support

Hi,

 

Adding dialog boxed could break the functionality. It's better to log the activity somewhere else:

http://adndevblog.typepad.com/manufacturing/2014/08/debug-ilogic.html

 

Cheers, 



Adam Nagy
Autodesk Platform Services
Message 3 of 11

Anonymous
Not applicable

Adding Dialog boxes is the only way, besides that tracer, to let you know where you are at in the code.  

 

Another issue is if I accidentally type a parameter name wrong.  It wont give an errror or "This parameter doesn't exist".  It will just go through the code and not do anything.  

0 Likes
Message 4 of 11

xiaodong_liang
Autodesk Support
Autodesk Support
Hi bret.leasure,

the best practice I know of is to test the code in VB.NET (Visual Studio) firstly. then copy to iLogic. It will save you much time to figure out the problems of syntax.
you just need a very simple skeleton of VB.NET EXE of an Inventor API.
0 Likes
Message 5 of 11

Curtis_Waguespack
Consultant
Consultant

Edit: Guess I was a little slow in replying! Bret, see this video for a quick idea of how to use the DebugView tool.

 

HI bret.leasure,

 

I completely agree that iLogic module need a better debugger. Often times if the error message would just tell me what line it's tripping over that would be enough.

 

In the mean time, I use this:

http://adndevblog.typepad.com/manufacturing/2014/08/debug-ilogic.html

 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

 

EESignature

Message 6 of 11

Anonymous
Not applicable

If I am going to spend the time to write the code in Visual Studio to test it, I will just keep it in Visual Studio and use the API instead of iLogic, which is what I am going to be doing because of the lack of debugging.  

 

At the very least, like Curtis said, even if iLogic would point out which line the issue is on, that wouuld be helpful.  

 

 

Message 7 of 11

wmgshurik
Enthusiast
Enthusiast

My way is pretty simple.

 

You make your own dll whith public method (no matter c# or VB. This method may do nothing, only one instruction to make a breakpoint.), add reference to this dll into your rule, call dll-method from rule.  Then start Inventor from Visual Studio and start your rule from Inventor. Breakpoint will work. After exit from method you are in your rule in VS debugger.

 

0 Likes
Message 8 of 11

Michael.Navara
Advisor
Advisor

I use VisualStudio for writing and debugging iLogic rules for a long time and it works well

You can see my GitHub repo   iLogic for VisualStudio and use it.

0 Likes
Message 9 of 11

wmgshurik
Enthusiast
Enthusiast

Hello friends!

There are some adjustments for 2025.

You need to create dll with Net8 target to debug Inventor 2025 in Visual studio.

My video shows this. If you click F10 you'll get inside your ilogic rule in the context of the IDE and all the power of the debugger is at your service.

 

Sincerely

0 Likes
Message 10 of 11

C_Haines_ENG
Collaborator
Collaborator

Gotta hit em with that Logger.Info("Problem Child") 

 

Better than having to pause your script to display a message box.

0 Likes
Message 11 of 11

JBerns
Advisor
Advisor

I have been using Visual Studio (VS) to debug iLogic code since Inventor 2019. Works for both internal and external rules.

Inspired by post by @BrianEkins 

https://modthemachine.typepad.com/my_weblog/2019/12/using-visual-studio-to-debug-ilogic-rules.html 

 

You can step through code, set multiple breakpoints, conditional breakpoints, etc. Such a valuable workflow.

 

I have attached the VS2022 SLN in Zip form which is compatible with Inventor 2025. Not sure if it works with INV2026.

 

Usage:

  1. Start Inventor.
  2. Start Visual Studio and open the SLN file.
  3. From the Visual Studio Debug Menu, select 'Attach to Process..."
  4. Select Inventor from the list.
  5. In Inventor, open a document containing an iLogic rule to debug.
  6. Edit the iLogic rule to include a 'Break' statement. On rare occasions, I have had to use 'Debugger.Break'
  7. When the Break statement is encountered, VS is activated. Step through code using F11.

For example:

Sub Main()
	Break
	Call Greet
End Sub

Sub Greet()
	MessageBox.Show("Hello, World!", "HELLO", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub

 

Hope this is helpful.

 

Regards,

Jerry

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional