Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Exiting (Breaking) Before Save Event Trigger

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
ReneRepina
739 Views, 5 Replies

Exiting (Breaking) Before Save Event Trigger

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

Labels (1)
5 REPLIES 5
Message 2 of 6
ReneRepina
in reply to: ReneRepina

I am using Inventor 2020.3.4.

Message 3 of 6

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:

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: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 !

Message 4 of 6
j.haggenjos
in reply to: ReneRepina

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
in reply to: j.haggenjos

@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!

Message 6 of 6
j.haggenjos
in reply to: ReneRepina

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report