Customized Event Triggers

Customized Event Triggers

sultan_mustun
Advocate Advocate
1,408 Views
5 Replies
Message 1 of 6

Customized Event Triggers

sultan_mustun
Advocate
Advocate

Hello,

I wanted to know if there is a way to customize the Event Triggers. Or are there some codes that can do that, rather than using the Event triggers?

 

For example in my case, I want to trigger an event when the Item number in the Parts List in my drawing changes. The goal is that if I change the Item number either via the Bill Of Materials or Manually it triggers the code.


For now I am triggering the rule Before saving.

 

Thank you for any help.

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

bradeneuropeArthur
Mentor
Mentor
Accepted solution

with a simple add-in you have the "parameterchange event" which is easier to use.

 

for ilogic

 

Sub Main()
Dim oModelEvent As ModelingEvents
oModelEvent = ThisApplication.ModelingEvents

AddHandler oModelEvent.OnParameterChange, AddressOf oModelEvent_ParameterChange
End Sub

Sub oModelEvent_ParameterChange(DocumentObject As _Document, Parameter As Parameter, BeforeOrAfter As EventTimingEnum, Context As NameValueMap, ByRef HandlingCode As HandlingCodeEnum)

If BeforeOrAfter = kBefore Then
MessageBox.Show("Before changing parameter : " & Parameter.Value)
ElseIf BeforeOrAfter = kAfter Then
MessageBox.Show("After changing parameter : " & Parameter.Value)
End If

End Sub

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

Message 3 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @sultan_mustun.  We can not change which events are available to use within the iLogic Event Triggers dialog.  We can unofficially add or remove rules under events on the 'This Document' tab by code, but we can not interact with the settings on any of the other tabs.  However, as @bradeneuropeArthur mentioned above, we can create custom event handler codes that will start 'listening' for specific events, then when those events happen, it will do something as a response.  But there are a limited set of events that we can listen for that way.  There are definitely more events to listen to using custom code than there are available in the Event Triggers dialog.  And if you listen to events using custom code, you can be much, much more specific about the details related to the events, so that you only respond to the event when certain other conditions are met, and can react in different ways depending on those details of the event.  However, there is no Event specifically for when you change the Item Number of an row in the assembly BOM, or for when you change that within a drawing's PartsList.  So, if it is possible to monitor for those actions, you would have to monitor a far more vague event, such as ApplicationEvents.OnDocumentChange Event.  But that event gets triggered a TON of times, for many different reasons, so any custom code you might use to monitor that event would need to be super efficient to keep from really slowing Inventor down.

Edit:  Attempting to monitor the DocumentEvents.OnChange Event (which is very similar in functionality) might be less intrusive / expensive to use, and will limit the monitoring to one specific document, instead of all documents.  Every Document type object has a DocumentEvents property which will return that DocumentEvents object.  Then when that document is truly and fully closed, that should get rid of the event monitoring that is running in the background that was started from the custom code.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 4 of 6

sultan_mustun
Advocate
Advocate

Thank you Both,

I'm using the code provided by @bradeneuropeArthur but on Document Change Event as suggested by @WCrihfield .

0 Likes
Message 5 of 6

cuentaichi001
Community Visitor
Community Visitor

Hi, how can I delete these messages box now? I deleted the rule I created with that code, and now I continuously have these boxes disturbing me

cuentaichi001_0-1756101294616.png

 

0 Likes
Message 6 of 6

sultan_mustun
Advocate
Advocate

Hi,

Just add a  " ' " before the MessageBox, to comment this portion, like this:

 If BeforeOrAfter = kBefore Then
'MessageBox.Show("Before changing parameter : " & Parameter.Value)
ElseIf BeforeOrAfter = kAfter Then
'MessageBox.Show("After changing parameter : " & Parameter.Value)
End If