Cannot run iLogic rule through API

Cannot run iLogic rule through API

Anonymous
Not applicable
1,469 Views
16 Replies
Message 1 of 17

Cannot run iLogic rule through API

Anonymous
Not applicable

Hi All,

 

In Inventor 2019 , when trying to run an iLogic rule through the API, iLogic cannot find the source of the *.vb it creates from the Rule in my Appdata\Local\Temp\iLogic Rules\ directory. 

 

When the debugger hits 'RunRule(oDoc, "TestRule")', it tries to search for 'TestPart.ipt.TestRule.glue.vb' inside of Temp\iLogicRules\ although it just created 'TestPart.ipt.TestRule.vb' inside of that same directory. When I rename 'TestPart.ipt.TestRule.vb' into 'TestPart.ipt.TestRule.glue.vb', it runs through the first line of the rule, and then it asks again for the location of 'TestPart.ipt.TestRule.vb'.

 

I have no idea where this .glue. comes from. Although 'TestPart.ipt.TestRule.vb' is being generated, at the start it searches for 'TestPart.ipt.TestRule.glue.vb'.

 

I searched the internet and a couple of forums, but unfortunately I cannot find any post similar to this.

 

Anybody have an idea? Any help would be highly appreciated.

 

KR,

Tinus

0 Likes
1,470 Views
16 Replies
Replies (16)
Message 2 of 17

MjDeck
Autodesk
Autodesk

Are you using Visual Studio?
Does the rule run correctly?
Is the fact that Visual Studio can't find the glue.vb file the only problem?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 3 of 17

Anonymous
Not applicable

Yes, I'm using visual studio express 2017. The rule runs succesfully, the only problem that occurs is an error message in my UI saying : 'This function cannot be run on a drawing document'.  (I'm trying to run a rule on drawing document) 

0 Likes
Message 4 of 17

MjDeck
Autodesk
Autodesk

Do you know which function is throwing that error?
Can you post the rule?


Mike Deck
Software Developer
Autodesk, Inc.

Message 5 of 17

Anonymous
Not applicable

Hello Mike, 

 

First of all, thanks for your help.

 

I recieve the 'This function cannot be run on a drawing document' error message on runtime in Inventor. Whilst debugging, the first mentioned .glue problem shows up when it hits the RunRule(oDoc, "RuleName") line. 

 

I have to mention that a 3rd party company recently developed and installed a vault addin that creates secondary documents on released state change. I already had to adjust my vault download functions, due to the fact that suddenly it started to aquire the wrong files. For example, instead of downloading partfile.ipt, it downloaded a file named partfile.ipt.stp. Is it possile that my problem could be related to the 3rd party development?

 

I'm sorry I can't post any Rule content right now, because I don't have access to my work laptop at the moment, but I tested the code on both complicated as wel as simple rules, but the result is the same. 

 

If you need any further information, please let me know. 

 

Regards, 

Tinus

 

 

 

0 Likes
Message 6 of 17

MjDeck
Autodesk
Autodesk

Hi Tinus,

The .glue.vb file is a temporary file created by the iLogic compiler. It contains code that connects the rule to the iLogic system. This is boilerplate code, and ideally the debugger shouldn't be looking for it. I'll try to figure out why that's happening.

But even though the glue source file is missing, you should still be able to debug into your rule. When you see the prompt, can you hit Step Out (Shift+F11) to continue?
If that doesn't work, you should be able to load the .vb file generated by your rule in Visual Studio and set breakpoints in that source file directly. If you do that, then you don't have to step through the RunRule statement. Instead, you can just set a breakpoint at the top of the rule.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 7 of 17

Anonymous
Not applicable

Hi Mike,

 

Thank you for your prompt reply. I'll test this first thing in the morning, and post you the results.

 

Tinus

0 Likes
Message 8 of 17

Anonymous
Not applicable

Hello Mike,

 

I've tested your suggestions, and the result is that now I'm able to debug through the rule by placing a break on the first line of the rule. By being able to debug through the rule, I was able to correct a mistake in my code, that gave me the 'This function cannot be run on a drawing document' error message.

 

With Shift-F11 I'm able to skip the 'find source .glue.vb' error message and the rule will run without any problems. The question still remains why .NET keeps asking for the .glue.vb file.

 

If you need any further information, please let me know.

 

King Regards,

Tinus

0 Likes
Message 9 of 17

MjDeck
Autodesk
Autodesk

You might be able to prevent Visual Studio from asking you for that file by changing a setting in Tools > Options > Debugging > General. Please try checking the "Enable Just My Code" option. Let me know if that doesn't work.

It looks like this is a (relatively minor) bug in our code. We want to make it so that the debugger never asks for the glue source. We use the DebuggerNonUserCode attribute to do that. But we should be using the DebuggerHidden attribute.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 10 of 17

Anonymous
Not applicable

Hello Mike,

 

The ''Enable Just My Code" option was already checked my Visual Studio, so although it is checked, VS still asks for the file. 

 

KR,

Tinus

 

 

0 Likes
Message 11 of 17

DRoam
Mentor
Mentor

@MjDeck wrote:

You might be able to prevent Visual Studio from asking you for that file by changing a setting in Tools > Options > Debugging > General. Please try checking the "Enable Just My Code" option. Let me know if that doesn't work.

It looks like this is a (relatively minor) bug in our code. We want to make it so that the debugger never asks for the glue source. We use the DebuggerNonUserCode attribute to do that. But we should be using the DebuggerHidden attribute.


FYI, @MjDeck, I was seeing the same "...glue.vb cannot be found" message for a rule with no code except "Break" in it. I looked at the "Just My Code" option and it was unchecked. I checked it on and the "...glue.vb cannot be found" message stopped appearing. So that fix worked for me.

 

But I remember I had to turn off Just My Code for some reason, so it would be nice to be able to leave it off. Any progress in fixing this so the debugger never asks for the glue source, even with Just My Code unchecked?

0 Likes
Message 12 of 17

MjDeck
Autodesk
Autodesk

Hi @DRoam , thanks for confirming that the "Just My Code" option works for you. I haven't looked at this problem recently. I'll take another look at it.
Maybe you could to a test:
- disable "Just My Code"
- before doing a test that would show the "file not found" message, try creating a dummy glue.vb file. The easiest way might be to create a copy of your existing file and rename it to "<existing name>.glue.vb"


Mike Deck
Software Developer
Autodesk, Inc.

Message 13 of 17

DRoam
Mentor
Mentor

Thanks for looking at it again, if it can be fixed without too much effort that would be great.

 

I tested what you said and it sort of worked (the message didn't appear) but the debugger execution arrow went to a random place in the .glue file and I had to hit F10 a couple of times before it moved into the non-glue vb file. I think going forward I'll just Step Out if I need to leave Just My Code disabled -- or I may enable Just My Code if doing a bunch of iLogic debugging.

 

On a related note, while you're here, can you explain what the "Use the legacy C# and VB expression evaporators" option does, and why it needs to be checked? When I check it in VS 2019, I get a message saying it's been deprecated and will be removed in future versions. Was wondering if you're aware of this? I tried unchecking it and I'm not seeing any issues, debugging still seems to be working, so I'm hoping it's not a super crucial thing?

0 Likes
Message 14 of 17

MjDeck
Autodesk
Autodesk

It's not super crucial. That option helps you to examine (in the Locals and Autos debug windows) the properties of COM objects from the Inventor API (e.g. Inventor.Document). If that option is not on, you have to drill into the Dynamic View of each object. But with that option, you get the properties as first class members.


The deprecated message has been in there for several releases of Visual Studio,  Hopefully Microsoft won't actually take it out. I did find a post asking them not to. I'll post a link if I can find it again, and add my vote to it.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 15 of 17

JBerns
Advisor
Advisor

I am developing with Inventor 2022.4.1 and Visual Studio 2022 Version 17.10.3

I too encounter the prompt (dialog box) for a missing glue.vb file.

Since I do not have a file, I select Cancel.

At that point VS switches from debugging in VB to C++. Very peculiar and annoying.

 

I too have toggled the "Just My Code" option, but the random, missing glue file prompt persists.

 

This started happening about six months ago after a VS update. Wish I knew the exact version when it happened.

I have attached a video.

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 16 of 17

MjDeck
Autodesk
Autodesk

Hi Jerry - you can prevent the C# code from coming up by unchecking this option under Debug > Options in Visual Studio:
"Automatically decompile to source when needed (Managed only)"
It's near the bottom of the list of General debug options.
If that is unchecked, Visual Studio will ask you what to do when it needs the glue.vb file. You can just hit F5 to continue running. It will proceed.

In Inventor 2025, we made a change to keep the glue.vb files in the temporary folder. That way Visual Studio can find them.


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 17 of 17

JBerns
Advisor
Advisor

Thanks, Mike,

I have disabled that option.

I will report after I debug a few rules.

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