iLogic "Break" Function

iLogic "Break" Function

Anonymous
Not applicable
2,258 Views
3 Replies
Message 1 of 4

iLogic "Break" Function

Anonymous
Not applicable

Hello,

 

Is there an iLogic break function similar to C or Python that I can trigger to break out of a loop/rule? I'd like to check whether a shared variable exists, and if it does then stop executing the rule.

 

Thanks,

Tighe

0 Likes
Accepted solutions (1)
2,259 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

iLogic's language is based on VB.NET. This means that there is no break function, but you can make use of Exit statements. 

0 Likes
Message 3 of 4

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @Anonymous 

Wether you specify it or not. iLogic runs in a Sub called Main.

If you're not in a specified sub (meaning you're in main) you can exit the entire rule with a simple Exit Sub statement.

All you'll need is this one line:

If SharedVariable.Exists("MySharedVariable") Then Exit Sub

Where "MySharedVariable" is the name of your shared variable.

Message 4 of 4

JBerns
Advisor
Advisor

If I may contribute to this slightly older post, if you are using Visual studio to debug your iLogic rule, you can include BREAK statements in your iLogic rule. I have been using VS to debug iLogic rules since Inventor 2019.

 

Execution will pause at a BREAK statement and control switches to Visual Studio.

Now you can Step, Step Over, Step Out of, Run to, and a few other debugging options.

 

A word of caution though - some VS debugging features that explore too deeply can crash Inventor without a chance to save, so be sure to save your document with local rules before debugging with VS. Other than that, using VS has really helped to expand my iLogic skills.

 

There are a number of threads that explain the VS Debug process. If you have implementation troubles, I can post the VS solution I am using with Inventor 2022.

 

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
0 Likes