Made a new addin with template and added two buttons. On gets the PDF translator and the other gets the STEP translator. PDF fails, STEP works.
Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Namespace InventorAddIn1
<ProgIdAttribute("InventorAddIn2.StandardAddInServer"), _
GuidAttribute("6a980868-cdce-4631-a170-77a49bf32c15")> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
' Inventor application object.
Private m_inventorApplication As Inventor.Application
Private WithEvents _GetPdfTraslatorButton As Inventor.ButtonDefinition
Private WithEvents _GetStepTraslatorButton As Inventor.ButtonDefinition
Public Shared AddInCLSID As String
#Region "ApplicationAddInServer Members"
Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
Try
' 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 _AddInCLSID As GuidAttribute = CType(System.Attribute.GetCustomAttribute(GetType(StandardAddInServer), GetType(GuidAttribute)), GuidAttribute)
AddInCLSID = "{" & _AddInCLSID.Value & "}"
Dim UserInterfaceManager As UserInterfaceManager = m_inventorApplication.UserInterfaceManager
' Get the ribbon associated with part documents
Dim DrawingRibbon As Ribbon = UserInterfaceManager.Ribbons.Item("Drawing")
' Create a new tab
Dim InventorAddIn2Tab As RibbonTab = DrawingRibbon.RibbonTabs.Add("InventorAddIn2", "InventorAddIn2.TranslatorsTab", AddInCLSID, , , False)
' Create a new panel within the tab
Dim TranslatorsRibbonPanel As RibbonPanel = InventorAddIn2Tab.RibbonPanels.Add("Translators", "InventorAddIn2.TranslatorsTab.TranslatorsPanel", AddInCLSID)
'Get icon
Dim IconIPictureDisp As Object = System.Type.Missing
'create the commands for the environment
Dim ControlDefinitions As Inventor.ControlDefinitions = m_inventorApplication.CommandManager.ControlDefinitions
_GetPdfTraslatorButton = ControlDefinitions.AddButtonDefinition("Get PDF translator", "InventorAddIn2.GetPdfTraslatorCmd", Inventor.CommandTypesEnum.kQueryOnlyCmdType, AddInCLSID, , , IconIPictureDisp, IconIPictureDisp)
_GetStepTraslatorButton = ControlDefinitions.AddButtonDefinition("Get STEP translator", "InventorAddIn2.GetStepTraslatorCmd", Inventor.CommandTypesEnum.kQueryOnlyCmdType, AddInCLSID, , , IconIPictureDisp, IconIPictureDisp)
' Create a control within the panel
Call TranslatorsRibbonPanel.CommandControls.AddButton(_GetPdfTraslatorButton, True)
Call TranslatorsRibbonPanel.CommandControls.AddButton(_GetStepTraslatorButton, True)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate
' This method is called by Inventor when the AddIn is unloaded.
' The AddIn will be unloaded either manually by the user or
' when the Inventor session is terminated.
' TODO: Add ApplicationAddInServer.Deactivate implementation
' Release objects.
m_inventorApplication = Nothing
System.GC.Collect()
System.GC.WaitForPendingFinalizers()
End Sub
Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation
' This property is provided to allow the AddIn to expose an API
' of its own to other programs. Typically, this would be done by
' implementing the AddIn's API interface in a class and returning
' that class object through this property.
Get
Return Nothing
End Get
End Property
Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand
' Note:this method is now obsolete, you should use the
' ControlDefinition functionality for implementing commands.
End Sub
#End Region
Private Sub _GetPdfTraslatorButton_OnExecute(Context As NameValueMap) Handles _GetPdfTraslatorButton.OnExecute
Try
Dim PdfTranslator As TranslatorAddIn
PdfTranslator = m_inventorApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
MsgBox("PDF TranslatorAddIn found")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Private Sub _GetStepTraslatorButton_OnExecute(Context As NameValueMap) Handles _GetStepTraslatorButton.OnExecute
Try
Dim StepTranslator As TranslatorAddIn
StepTranslator = m_inventorApplication.ApplicationAddIns.ItemById("{90AF7F40-0C01-11D5-8E83-0010B541CD80}")
MsgBox("STEP TranslatorAddIn found")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
End Class
End Namespace