MessageBox, Triggers

MessageBox, Triggers

mgrenier1
Advocate Advocate
728 Views
6 Replies
Message 1 of 7

MessageBox, Triggers

mgrenier1
Advocate
Advocate

I have setup a simple iLogic rule, just a message box

MessageBox.Show("Message", "Title", MessageBoxButtons.OK, MessageBoxIcon.Warning)

Capture d’écran 2023-10-12 114253.png

 

I have also setup a trigger to run the rule after i open the document

 

Capture d’écran 2023-10-12 113800.png

 

If I execute the rule manually everything is fine, however if it runs via the trigger the message box popup like 4 or 5 more times after I click it's OK button. I can't figure out what is wrong with it.

0 Likes
Accepted solutions (1)
729 Views
6 Replies
Replies (6)
Message 2 of 7

mgrenier1
Advocate
Advocate

I also just noticed the message pops up whenever I change page or update the model

0 Likes
Message 3 of 7

WCrihfield
Mentor
Mentor

Hi @mgrenier1.  Interesting situation.  Do you have the same rule, or same message in multiple different documents?  Did you know that when you open assemblies or drawings, that will cause all of the documents that they reference to also be opened invisibly (in the background, with no document tab showing)?  You can see the number of documents open by the number in the lower right corner of the Inventor screen, within the 'status bar'.  When that happens, it will trigger that event, and run the rule.  Just making sure you are aware of that.  Is it possible that is what is happening?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 4 of 7

mgrenier1
Advocate
Advocate

Yes, I think this is what is happening, I have the same rule in both the assembly and drawing. Is there a way to have it in both without the message popping up multiple times?

0 Likes
Message 5 of 7

WCrihfield
Mentor
Mentor
Accepted solution

Maybe.  It depends on how you need it to work.  I can not read what is within the message in your screen captured image, so I am not sure what the purpose of showing the message is.  If you only want the message to show for the document that is actively showing on your screen at that time, then you may be able to add a little bit of extra code to the rule to make it behave that way.  Like this maybe:

Dim oDoc As Document = ThisDoc.Document
Dim oVisibleDoc As Document = ThisApplication.ActiveDocument
If oDoc Is oVisibleDoc Then
	MessageBox.Show("Message", "Title", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If

Where the term 'ThisDoc.Document' will be referencing the Document that the event was fired from, and the term 'ThisApplication.ActiveDocument' will be referencing the Document that is showing on your screen at that time.  If those two are not the same Document, then do not show the message.  That is just one possible scenario though, and I am not exactly sure how you need to control it yet.  Another thing you could include in the message is the DisplayName (or some other unique identifier of the document) within the message, but that would just let you know which document the message launched from, not how to control it.  Using the generic events in the Event Triggers dialog is very handy, but it does not give you the same level of control as custom event handlers that are used in Inventor add-ins, unfortunately.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 6 of 7

mgrenier1
Advocate
Advocate

It's basically just a warning saying the model uses model states and to be careful when modifiying dimensions/parameters or constraints. I'll give your code a try and let you know if it works for me, thanks a lot.

0 Likes
Message 7 of 7

Frederick_Law
Mentor
Mentor

That trigger is off by default, for good reason:

iLogic-07.jpg

 

Which version IV are you using?

IV2023.4 the message box only open once.

iLogic-08.jpg

0 Likes