06-06-2016
04:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-06-2016
04:48 AM
Hi,
this is how I add event triggers to the standardAddInServer:
at the start of the namespace i add the line
Private WithEvents oAppEvents As ApplicationEvents
as shown:
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
'Application events object
Private WithEvents oAppEvents As ApplicationEvents
This means I can them select oAppEvents from the left dropdown above yor code window, and from the right one you have a full set of event triggers ready. to use.
I Can then choose OnActivateDocument and I get the empty sub as below:
Private Sub oAppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles oAppEvents.OnActivateDocument
End SubAs you might've guessed, any code in here will fire upon a docuement being made active, eg switching between two docs.
but this trigger, as with all triggers will fire twice, once before the event and once after it. this is why you're seeing it happen twice,
To prevent this you need to tell the sub when you want it to fire, either before or after the event like this:
Private Sub oAppEvents_OnActivateDocument(ByVal DocumentObject As Inventor._Document, ByVal BeforeOrAfter As Inventor.EventTimingEnum, ByVal Context As Inventor.NameValueMap, ByRef HandlingCode As Inventor.HandlingCodeEnum) Handles oAppEvents.OnActivateDocument
'fire after document is made active
If BeforeOrAfter = EventTimingEnum.kAfter Then
End If
'fire before document is made active
If BeforeOrAfter = EventTimingEnum.kBefore Then
End If
End Sub
hope this helps.