Exiting (Breaking) Before Save Event Trigger

Exiting (Breaking) Before Save Event Trigger

ReneRepina
Collaborator Collaborator
1,370 Views
5 Replies
Message 1 of 6

Exiting (Breaking) Before Save Event Trigger

ReneRepina
Collaborator
Collaborator

Hello,

 

is there any possibility to exit (break) before save event trigger?

 

For example. We have several iRules which are run Before Save (event trigger). First one is checking if correct "Project File" is selected, if it is, continue executing other Before Save iRules, but if it is not correct one, exit (break) the Before Save Event Trigger to prevent executing further iRules on Before Save (causing errors obviously).

 

 

Best regards,

Rene Repina

0 Likes
Accepted solutions (3)
1,371 Views
5 Replies
Replies (5)
Message 2 of 6

ReneRepina
Collaborator
Collaborator

I am using Inventor 2020.3.4.

0 Likes
Message 3 of 6

bradeneuropeArthur
Mentor
Mentor
Accepted solution

With the build in application events of ilogic this is not possible to skip I am afraid.

With the use of an addin this is possible to do in some kind of way. For example on command start event.

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 6

j.haggenjos
Advocate
Advocate
Accepted solution

There is a way to make it work. I used a similar technique  before moving to an AddIn to have more control.

 

In your base rule, you create a Shared Variable, and in the other rules, based on the value in the shared variable, you can decide to run or not. The rule are always run, but you can just decide to skip them.

 

Main rule:

If ProjectFile is Correct Then
     SharedVariable("ShouldTriggerRun") = True
Else
     SharedVariable("ShouldTriggerRun") = False
End If

 

And in your other rules:

 

If SharedVariable.Exists("ShouldTriggerRun") AndAlso Not SharedVariable("ShouldTriggerRun") Then Exit Sub

 

 

Message 5 of 6

ReneRepina
Collaborator
Collaborator

@bradeneuropeArthur 

Ah, too bad. Addin could work, but we are trying to do without them. Thanks anyway!

 

@j.haggenjos 

Thank you for the answer!

This could work yes, with NameValueMap or something similiar, but we have a lot of rules and we would have to include this in all of them.

Currently we have one main iRule which is in Event Triggers and this iRule is calling others. We have similiar concept as you described. Because we have only 1 iRule in Event Triggers, we exit that one if something goes wrong, but it is not optimal, since in some cases, it should exist in some middle iRule.

 

Thanks for answers and new options!

0 Likes
Message 6 of 6

j.haggenjos
Advocate
Advocate
Accepted solution

For fine control of event, I would go the AddIn route as suggested by @bradeneuropeArthur .

 

However, in both AddIn and iLogic rule, using boolean flags to decide on how to process the event will be my suggestion. You can turn on the flag anywhere in your code and then later, depending if a flag is on or not, react accordingly.


In your example of exiting in the middle of a rule:

 

At some point in one rule:

 

If condition is met Then SharedVariable("StopInMiddle") = True

 

 

And in the other rule:

 

Do something
If SharedVariable.Exists("StopInMiddle") Then
    SharedVariable.Remove("StopInMiddle")
    Exit Sub
End If
Do some more thing only if flag is off

 

 

The good thing with SharedVariable is that you can access them from any rules at any time. You don't have to pass argument around between rules. Similarly as how you would use global variables in an AddIn.

 

In my example here, I consider the flag to be used only for one thing. So the variable existence is enough to decide and I can remove the flag before going further. It doesn't need to be implemented in all the rules. Only the rule where you "decide" that you want to stop the other rule in the middle, and in the rule that you actually need to exit early. All the other rules will just ignore the shared variable.

0 Likes