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: 

Add multiple event triggers for external rules.

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
j3scat
316 Views, 5 Replies

Add multiple event triggers for external rules.

Can someone point me to the latest valid instructions to create an ilogic rule that will add add event triggers?

 

I've built my rule by piecing together various bits of code from here and there in the forum. I can get a before save event trigger to work, but once I try adding an "Any Model Parameter Change" trigger, this rule and/or any subsequent rules will not trigger. The non-working rules do appear in the event triggers dialog.

 

I can delete the trigger, then add it manually and it will fire as intended.

 

Many of the links I try to follow are broken or not applicable. I think I need to recreate my rule from scratch, utilizing the latest known good routine for adding event triggers.

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

Hi @j3scat.  This process is entirely user originated, so there is no official set of instructions for it.  That has been a known issue for years now.  There is a small detail that most folks miss in this process.  I actually believe that one of the Autodesk employees helped us figure it out once, not too long ago.  I believe that you may simply need to have at least one other internal iLogic rule saved within the target document before you create and / or edit that hidden PropertySet, or the edits will not get properly registered behind the scenes.  When you add an internal iLogic rule to a document, that adds what is known as a DocumentInterest to the Document for the iLogic add-in, which seems to be part of what is needed.  But you can not simply add a DocumentInterest to the Document directly, without there actually being anything in the document that is iLogic related, or it seems it will just disappear again.  Try that and let us know if that helps.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 6
j3scat
in reply to: WCrihfield

Well, I'll be.

The rule that I added via my create triggers rule, that always worked on "Before Save" was "Check PartNumber". I manually added that rule. Then I ran my 'Set Triggers' rule. My subsequent added rules seem to trigger correctly.

I didn't add an internal rule. I simply added one rule manually first. I don't know if it is a consistent fix yet.

I know that isn't what you directed me to do, as I misread your instructions, but I figured my result was worth posting.

I will now try creating an internal rule first, then see if that fixes my situation shortly
Message 4 of 6
WCrihfield
in reply to: j3scat

Thanks for the feedback.  While I was waiting, I looked around a bit through older forum posts that include the term "Event Triggers", and I found a thread that was started back in 2019, where Mike Deck (Autodesk employee and guru of all things Inventor API and iLogic related) responded to one of these inquiries and mentioned this little trick.

https://forums.autodesk.com/t5/inventor-programming-ilogic/adding-external-rule-to-event-trigger/m-p... 

...but I think I was thinking of another similar post later than that one that I may have been trying to help out with at the time.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 5 of 6
j3scat
in reply to: j3scat

That last link was very helpful.

 

In that thread it looked like the routine was to check for the required 'DocumentInterest'. If not found, create an internal rule, create the external rule trigger, then delete the internal rule.

 

In my code, I added a subroutine that tries performing the DocumentInterest check. When it doesn't find the required property set, Create an internal rule and immediately delete it. After returning to the Main sub, my code then adds the external rule triggers.

 

My initial test was a failure. However, if I run my create triggers rule twice; everything works.  I double checked running my rule twice without calling the DocumentInterest propertyset check and the triggers don't fire.  So far, with consistent testing, as long as I run the rule(that creates and deletes a blank internal rule) twice, my triggers function correctly.

Message 6 of 6
WCrihfield
in reply to: j3scat

Good to hear.  I generally do the check at the beginning of my routine that will be editing the event triggers property set, then if it is not found, I add a rule named "DeleteMe" to the target document, then do all the editing needed, then check for a rule with that name in the target document, and if found, delete it.  I was trying to use a single routine, either at the start, or at the end for a while too, but I believe after I split that added routine into two smaller chucks added to my regular routine for editing the PropertySet, that's when it started working better for me.  Another thing that helps is having some internal iLogic rules and/or Event Triggers settings present in the 'template' files, that you start all your other new files from.  That seems to carry over to the new files that are created from those templates, so that I do not have these troubles when dealing with them.  I learned this from another user who was asking similar questions before.  He was having these problems, but I wasn't, so he sent me a file to test on, and that file would cause the problems.  I realized that most of my templates already had a 'history' of internal iLogic rules & event triggers settings, so I tried creating some truly NEW files from the templates provided by Autodesk, instead of from my own custom templates, then I started seeing those problems with those new files.  That seemed to be part of the issue that helped me understand that there needed to be something in the file related somehow to the iLogic add-in.  Then I saw another post from Mike Deck somewhere where he mentioned that little detail about the DocumentInterest and the trick with the temporary internal iLogic rule.  It seems that either situation (internal iLogic rules being present, or event triggers settings having been created manually in it before) will cause there to be the needed DocumentInterest present.

The technique of editing that hidden PropertySet to edit the Event Triggers dates all the way back to early 2012 when users (primarily a person with user name "MegaJerk") started posting about their discoveries after doing a lot of trial & error snooping / testing.

https://forums.autodesk.com/t5/inventor-programming-ilogic/api-set-an-event-trigger-for-an-ilogic-ru... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

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

Post to forums  

Autodesk Design & Make Report