Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AddIn Button Won't Load

1 REPLY 1
Reply
Message 1 of 2
mmdmc
397 Views, 1 Reply

AddIn Button Won't Load

I'm trying to create a registry-free addin here using Inventor 2013 and VB Express 2013. I've been using the AddIn template for VB.NET and  http://modthemachine.typepad.com/files/VBAtoAddIn.pdf to create the addin, but the button I created (and the addin I assume), won't appear in Inventor.

 

-Both the addin file and dll are in %APPDATA%\Autodesk\Inventor 2013\, and VB Express is pointed to build there.

-I've tried .Net 3.5, 4, and 4.5

-Inventor 2013 Build 138, 03/01/12

 

The .addin code:

<Addin Type="Standard">
  <!--Created for Autodesk Inventor Version 17.0-->
  <ClassId>{63e02af8-a71d-4c70-8319-75da45602d4f}</ClassId>
  <ClientId>{63e02af8-a71d-4c70-8319-75da45602d4f}</ClientId>
  <DisplayName>PCB_Importer_AddIn</DisplayName>
  <Description>PCB_Importer_AddIn</Description>
  <Assembly>%APPDATA%\Autodesk\Inventor 2013\Addins\PCB_Importer_AddIn.dll</Assembly>
  <!--<LoadOnStartUp>1</LoadOnStartUp>--> 
  <UserUnloadable>1</UserUnloadable>
  <Hidden>0</Hidden>
  <SupportedSoftwareVersionGreaterThan>16..</SupportedSoftwareVersionGreaterThan>
  <DataVersion>1</DataVersion>
  <UserInterfaceVersion>9</UserInterfaceVersion>
  <LoadBehavior>2</LoadBehavior>
  <LoadAutomatically>1</LoadAutomatically>
</Addin>

 

The Activate sub and ribbon creation sub:

 

        Private m_inventorApplication As Inventor.Application
        Private m_ClientID As String
        Private WithEvents m_buttonDef As ButtonDefinition
        Private WithEvents userInterfaceEvents As UserInterfaceEvents

#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
            m_ClientID = AddInGuid(GetType(StandardAddInServer))

            ' TODO:  Add ApplicationAddInServer.Activate implementation.
            ' e.g. event initialization, command creation etc.

            ' Get a reference to the UserInterfaceManager object. 
            Dim UIManager As Inventor.UserInterfaceManager = m_inventorApplication.UserInterfaceManager
            
            ' Get the control definitions collection.
            Dim controlDefs As ControlDefinitions = m_inventorApplication.CommandManager.ControlDefinitions

            'Dim smallPicture As IPictureDisp = PictureDispConverter.ToIPictureDisp(My.Resources.icon16)

            'Set the large icon size based on wheter it is the classic or ribbon interface
            'Dim largePicture As IPictureDisp
            'If UIManager.InterfaceStyle = InterfaceStyleEnum.kRibbonInterface Then
            '    largePicture = PictureDispConverter.ToIPictureDisp(My.Resources.icon32)
            'Else
            '    largePicture = PictureDispConverter.ToIPictureDisp(My.Resources.icon24)
            'End If

            'Set the addin button definition
            Try
                m_buttonDef = controlDefs.Item("AltiumImportButton")
            Catch ex As Exception
                m_buttonDef = controlDefs.AddButtonDefinition(DisplayName:="Altium Importer", InternalName:="AltiumImportButton", Classification:=CommandTypesEnum.kEditMaskCmdType, _
                                                         ClientId:=m_ClientID)
            End Try       

            If (firstTime) Then
                If UIManager.InterfaceStyle = InterfaceStyleEnum.kRibbonInterface Then
                    CreateOrUpdateRibbonUserInterface()
                ElseIf UIManager.InterfaceStyle = InterfaceStyleEnum.kClassicInterface Then
                    CreateClassicInterface()
                End If
            End If

        End Sub

        ' This property uses reflection to get the value for the GuidAttribute attached to the class.
        Public Shared ReadOnly Property AddInGuid(ByVal t As Type) As String
            Get
                Dim guid As String = ""
                Try
                    Dim customAttributes() As Object = t.GetCustomAttributes(GetType(GuidAttribute), False)
                    Dim guidAttribute As GuidAttribute = CType(customAttributes(0), GuidAttribute)
                    guid = "{" + guidAttribute.Value.ToString() + "}"
                Finally
                    AddInGuid = guid
                End Try
            End Get

        End Property

        'Create User Interface
        Private Sub CreateOrUpdateRibbonUserInterface()
            'Get a reference to the UserInterfaceManager object.
            Dim UIManager As Inventor.UserInterfaceManager = m_inventorApplication.UserInterfaceManager

            'Get the assembly ribbon
            Dim assemblyRibbon As Inventor.Ribbon = UIManager.Ribbons.Item("Assembly")

            'Get the "Assemble" tab
            Dim assembleTab As Inventor.RibbonTab
            assembleTab = assemblyRibbon.RibbonTabs.Item("id_TabAssemble")

            'Create a new panel on the Assembly tab
            Dim panel As Inventor.RibbonPanel
            panel = assembleTab.RibbonPanels.Add(DisplayName:="PCB Importer", InternalName:="AssembleTabPCBImporterPanel", ClientId:=m_ClientID)

            'Add the button to the tab
            panel.CommandControls.AddButton(m_buttonDef, True)
        End Sub
#End Region

 

Thanks

1 REPLY 1
Message 2 of 2
adam.nagy
in reply to: mmdmc

Hi,

 

Try to put a break point at the beginning of the Activate method.

If it does not get enabled when Inventor starts then maybe the wrong dll is loaded or it has some unresolved dependency.

If it does get enabled then you can step through the code and see if all goes fine.

 

In theory even in VB Express you can do debugging by editing the project file in a text editor and adding some entries.

 

Cheers,



Adam Nagy
Autodesk Platform Services

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report