
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello Everyone,
I have a problem with the onchange event. Please help me in this case.
Here's my code: Add-in!
Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Namespace TTF
<ProgIdAttribute("TTF.StandardAddInServer"), _
GuidAttribute(g_simpleAddInClientID)> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
Private WithEvents m_uiEvents As UserInterfaceEvents
Private WithEvents m_onChangeEvents As DocumentEvents
#Region "ApplicationAddInServer Members"
Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
Try
g_inventorApplication = addInSiteObject.Application
m_uiEvents = g_inventorApplication.UserInterfaceManager.UserInterfaceEvents
If (Not g_inventorApplication.ActiveDocument Is Nothing) Then
m_onChangeEvents = g_inventorApplication.ActiveDocument.DocumentEvents
End If
' Add to the user interface, if it's the first time.
' If this add-in doesn't have a UI but runs in the background listening
' to events, you can delete this.
If firstTime Then
AddToUserInterface()
End If
Catch ex As Exception
MsgBox("Unexpected failure in the activation of the add-in ""TTF""" & vbCrLf & vbCrLf & ex.Message)
End Try
End Sub
Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate
' Release objects.
m_onChangeEvents = Nothing
m_uiEvents = Nothing
g_inventorApplication = Nothing
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
End Sub
Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation
Get
Return Nothing
End Get
End Property
Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand
End Sub
Private Sub m_onchangeEvents_OnChange(ByVal ReasonsForChange As CommandTypesEnum,
ByVal BeforeOrAfter As EventTimingEnum,
ByVal Context As NameValueMap,
ByRef HandlingCode As HandlingCodeEnum) Handles m_onChangeEvents.OnChange
MsgBox("Onchange")
End Sub
#End Region
#Region "User interface definition"
Private Sub AddToUserInterface()
End Sub
Private Sub m_uiEvents_OnResetRibbonInterface(Context As NameValueMap) Handles m_uiEvents.OnResetRibbonInterface
' The ribbon was reset, so add back the add-ins user-interface.
AddToUserInterface()
End Sub
#End Region
End Class
End Namespace
Public Module Globals
' Inventor application object.
Public g_inventorApplication As Inventor.Application
' The unique ID for this add-in. If this add-in is copied to create a new add-in
' you need to update this ID along with the ID in the .manifest file, the .addin file
' and create a new ID for the typelib GUID in AssemblyInfo.vb
Public Const g_simpleAddInClientID As String = "45065451-f806-4680-8d84-4d2166b2b77a"
Public Const g_addInClientID As String = "{" & g_simpleAddInClientID & "}"
End Module
Solved! Go to Solution.