Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

You can use handlers to let your code respond to events in Inventor.

I use this for application events in my visual studio project:

 

Public Class ApplicationEvents
Implements Inventor.ApplicationAddInServer
Private AppEvents As Inventor.ApplicationEvents

Public InventorApp As Inventor.Application

 

Public Sub Activate(siteObj As Inventor.ApplicationAddInSite, loaded1stTime As Boolean) Implements ApplicationAddInServer.Activate

InventorApp = siteObj.Application

AppEvents = InventorApp.ApplicationEvents

AddHandler AppEvents.OnActivateDocument, AddressOf oAppEvents_OnActivateDocument

End Sub

 

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
If BeforeOrAfter = EventTimingEnum.kBefore Then
'your code here
End If
End Sub

 

Public Sub Deactivate() Implements ApplicationAddInServer.Deactivate

 

If InventorApp IsNot Nothing Then
Marshal.FinalReleaseComObject(InventorApp)
End If

End Sub