Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
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: 

Customized Event Triggers

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
sultan_mustun
359 Views, 3 Replies

Customized Event Triggers

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.

3 REPLIES 3
Message 2 of 4

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:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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 3 of 4
WCrihfield
in reply to: sultan_mustun

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 4

Thank you Both,

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

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

Post to forums  

Autodesk Design & Make Report