Adam,
thank you for your respond. I figured out how to unload the addin. I think I missed something and it doesn`t want to load back when I checking the box loaded/unloaded.
Below is the part of the code. Can you please look at it and point me into the right direction?
Public Module Globals
Public m_inventorApplication As Inventor.Application
End Module
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
' Inventor application object.
Private _buttonDef As ButtonDefinition
Private panel As RibbonPanel
#Region "ApplicationAddInServer Members"
Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
' This method is called by Inventor when it loads the AddIn.
' The AddInSiteObject provides access to the Inventor Application object.
' The FirstTime flag indicates if the AddIn is loaded for the first time.
' Initialize AddIn members.
m_inventorApplication = addInSiteObject.Application
' TODO: Add ApplicationAddInServer.Activate implementation.
' e.g. event initialization, command creation etc.
Dim clientId As String = "68aeeec3-0364-4ae5-a6ff-9e8dc99e0e13"
Dim smallicon As stdole.IPictureDisp
Dim largeicon As stdole.IPictureDisp
'Convert icon
smallicon = clsPictureConverter.ToIPictureDisp(My.Resources.tag_purple16x16)
largeicon = clsPictureConverter.ToIPictureDisp(My.Resources.tag_purple_32x32)
_buttonDef = m_inventorApplication.CommandManager.ControlDefinitions.AddButtonDefinition( _
"Add part", "id_TabVP", CommandTypesEnum.kQueryOnlyCmdType, clientId, "TParts", "TParts", _
smallicon, largeicon, ButtonDisplayEnum.kDisplayTextInLearningMode)
AddHandler _buttonDef.OnExecute, AddressOf OnExecute
Try
panel = m_inventorApplication.UserInterfaceManager.Ribbons("Assembly").RibbonTabs("id_TabAssemble").RibbonPanels("TParts")
Catch ex As Exception
panel = m_inventorApplication.UserInterfaceManager.Ribbons("Assembly").RibbonTabs("id_TabAssemble").RibbonPanels.Add( _
"TParts", "id_TabVP", clientId)
End Try
panel.CommandControls.AddButton(_buttonDef)
End Sub
' unloads addin
Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate
Try
'release objects
If Not panel Is Nothing Then panel.Delete()
Marshal.ReleaseComObject(m_inventorApplication)
_buttonDef = Nothing
m_inventorApplication = Nothing
System.GC.WaitForPendingFinalizers()
System.GC.Collect()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
I also looked at the SimpleAddin - I see there are three Handlers : OnResetCommandBars, OnResetEnviroments and OnResetRibbonInterfaceI assume they don`t do anything with load/unload behavior, and need only if user resets the ribbons manually thru the Ribbon Appearance.
Thank you.