iLogic Visual Studio Debugging

iLogic Visual Studio Debugging

Genicee
Advocate Advocate
1,997 Views
9 Replies
Message 1 of 10

iLogic Visual Studio Debugging

Genicee
Advocate
Advocate

I have been using Visual Studio to debug my iLogic for sometime now. Something changed recently or I did something that prevents Visual Studio from loading the iLogic Rule so I can step through the code. It has shown various errors with different things I have tried like the attached image. I have followed guide at the https://modthemachine.typepad.com/my_weblog/2019/12/using-visual-studio-to-debug-ilogic-rules.html 

 

The code in the rule I am using is super basic. 

Public Sub Main()	
	Dim oDoc As Document = ThisApplication.ActiveDocument	
	Throw New Exception("STOP")	
End Sub

 

0 Likes
1,998 Views
9 Replies
Replies (9)
Message 2 of 10

Maxim-CADman77
Advisor
Advisor

Nowadays I've got stuck debugging my ~1000 lines iLogic Rule (giving Exception HResult 0x80004005 on the particular sample). Of course I'd like to try debug it with Visual Studio (I used to code with Notepad++).


I've tried to follow the article (by @MjDeck) you've mentioned.

First of all, I should admit that there is no "Use the legacy C# and VB expression evaluators" option in Options/Debugging/General of actual VS version*.

Nevertheless I've (hopefully) managed to enable this option using the trick**. 

 

I then attached VS to Inventor 2023.1 process.

 
When I execute my EXTERNAL iLogic rule it produces exception error window.
 
I expect some data be shown in Watch/Autos/Locals window of VS ... but there is nothing there.
 
Could you comment the statement "However, note that "the code" that you see in VS is not exactly your original code from your rule."? 
Where I supposed to "see the code" if no VB project open is necessary (I thought I can debug iLogic with VS opened with option "Continue without code")? 
 
What I'm missing?
 
I'm using VS Community 2019 (Version 16.11.18)
 
**
See message marked as solution in the thread

 

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 3 of 10

MjDeck
Autodesk
Autodesk

@Maxim-CADman77 , iLogic creates a modified copy of your original rule as a .vb file in this folder:

 

%Temp%\iLogic Rules

 

Use File > Open in Visual Studio to open a .vb file from that folder. Then you can set a breakpoint in that file in Visual Studio.
This copy is the debuggable version of your rule. (The original rule is not directly debuggable, even if it is an external rule text file.)


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 4 of 10

Maxim-CADman77
Advisor
Advisor

Wow!! Debugging iLogic Rule by means of Visual Studio seems really cool thing!


PS: The reason why it behaved not as expected on my config on first attempt was system environment variable “iLogicRuleFolderForVS” with "0" value (can't remember circumstances of creating it).

 

Many Thanks to @MjDeck for guessing this!
(IMHO appropriate note is worth to be added to the article)

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 5 of 10

JelteDeJong
Mentor
Mentor

There is also another way to write/debug rules in VS. Check this post "Writing and debugging iLogic rules".

But if your iLogic rules have ~1000 lines of code you should consider writing an addin. You might want to have a look at this post "Creating an Inventor Addin". In that post, I create an addin from an iLogic rule.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 6 of 10

Maxim-CADman77
Advisor
Advisor

@JelteDeJong 
I'm not sure I understand you correctly.
By "writing the addin" together with mention your article you suggest to "wrap" iLogic code into addin (or convert it to Net language)?

I tried to convert iLogic to VB.Net but stuck (see - https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/invalid-callee-on-findusingvector-co...)

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 7 of 10

Maxim-CADman77
Advisor
Advisor

@JelteDeJong 

Have tried to follow your article "Creating an Inventor Addin" and ended up with error "Type 'ICadDoc' is not defined".

UPDATE: Solved with including Autodesk.iLogic.Interfaces library.
Now I have my first addin done!!

 

PS:
I believe I've found couple typos:

1. Double "Create a class “AbstractRule” ..." (second should be "ThisRule").

2. Code of StandardAddInServer ... line 3 ... "fiel" instead of "file".

3. In article about Icons ... in code ... wrong name for large icon (...16x16).

Please vote for Inventor-Idea Text Search within Option Names

Message 8 of 10

JelteDeJong
Mentor
Mentor

I changed the typo's thanks for pointing those out.

 

About your Idea: "Icon Customization for external iLogic rule ribbon". You might want to look at my addin "ButtonConstructor". That addin will allow you to change the icons of your buttons. 😉

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 9 of 10

Maxim-CADman77
Advisor
Advisor

@MjDeck 
Dear, Mike
Don't you know why Inventor (2025.2.1) Viewport may not update during iLogic code step-by-step debugging with Visual Studio (Community 2022)?
Like with Application.ScreenUpdating = False (I don't use it).

Please vote for Inventor-Idea Text Search within Option Names

0 Likes
Message 10 of 10

MjDeck
Autodesk
Autodesk

Hi @Maxim-CADman77 - if you are modifying a parameter directly in the rule, the display will probably not update until you execute these two lines of code:

RuleParametersOutput()
InventorVb.DocumentUpdate()

For debugging, you might want to add extra statements like that.

You can also add statements like:

ThisApplication.ActiveView.Update()

and

ThisApplication.UserInterfaceManager.DoEvents()

 

If none of those make a difference, please post some sample code that shows the problem.

 


Mike Deck
Software Developer
Autodesk, Inc.