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: 

Adding buttons to the same custom ribbon panel from two seperate add-ins.

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
Anonymous
2059 Views, 10 Replies

Adding buttons to the same custom ribbon panel from two seperate add-ins.

I used the code below to create a new ribbon panel

 

panel = assembleTab.RibbonPanels.Add("Button Name", "oNewButton", "m_ClientID")

 

I'm confused =how the clientID works, I assumed if they matched it would know it's the same panel. I'm try to get two different add-ins to add buttons to the same custom ribbon panel. Any ideas?

10 REPLIES 10
Message 2 of 11
saseendrankombath
in reply to: Anonymous

Access the panel with its internal name. You have to add the panel creation code to both addinns because if one loads first with out panel creation will not work. see the example below which will help you. I used the panel creation code in more than one Addin

 

Dim Multi_Body_Panel As Inventor.RibbonPanel
                    Try
                        Multi_Body_Panel = oPart_AddInTab.RibbonPanels("id_PanelP_Multi-Body")
                    Catch ex As Exception
                        Multi_Body_Panel = oPart_AddInTab.RibbonPanels.Add("Multi-Body", _
                                                                "id_PanelP_Multi-Body", ThisGuidString, , )
                    End Try

                    Multi_Body_Panel.CommandControls.AddButton(Rename_Solid_BtnDef, True, True, , )

 

Message 3 of 11
Anonymous
in reply to: saseendrankombath

What does the GUID need to be? Match the add-in that it is in or make them the same? I did both ways and it creates two of the same named panel. I can't get it to reuse the other.

Message 4 of 11
saseendrankombath
in reply to: Anonymous

GUID is the ClientID of the Addin. use the "Try :Catch :End Try" to check the ribbon is available if not create it. if this is added to both the addins the ribbon will be created once for the first loaded addin and the second addin will use the existing Ribbon.

Message 5 of 11

Hi Thomas,

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 6 of 11
Anonymous
in reply to: philippe.leefsma

Ok, I think I'm getting closer. Now it doesn't create two panels but it fails to add the 2nd add-ins button to the panel even though it does elsewhere and is loading and running ok. Here's my code:

 

 

                Try

                Dim oPanel As Inventor.RibbonPanel
                    oPanel = DWGToolsTab.RibbonPanels.Item("id_RibbonTab")


                Catch ex As Exception

                End Try

            If oPanel Is Nothing Then
                oPanel = DWGToolsTab.RibbonPanels.Add("Panel Name", "id_RibbonTab", "{GUID}")
            End If


            Try
                '## Add the button to the panel
                oPanel.CommandControls.AddButton(m_ButtonDefinition, True)

            Catch ex As Exception


            End Try

 

 

Message 7 of 11
philippe.leefsma
in reply to: Anonymous

Works perfectly on my side, take a look at the attached project ...

 

Testing under 2014

 

ribbon.png



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 8 of 11
saseendrankombath
in reply to: Anonymous

Try modifying as below

Dim oPanel As Inventor.RibbonPanel
 Try
               
                    oPanel = DWGToolsTab.RibbonPanels.Item("id_RibbonTab")


                Catch ex As Exception
                oPanel = DWGToolsTab.RibbonPanels.Add("Panel Name", "id_RibbonTab", "{GUID}")
                End Try

                '## Add the button to the panel
                oPanel.CommandControls.AddButton(m_ButtonDefinition, True)

 

Message 9 of 11
Anonymous
in reply to: philippe.leefsma

I think the single line of code method was the trick, this worked:

 

            Try
                panel = m_inventorApplication.UserInterfaceManager.Ribbons("Part").RibbonTabs("id_TabTools").RibbonPanels("id_ADNTab")
            Catch ex As Exception
                panel = m_inventorApplication.UserInterfaceManager.Ribbons("Part").RibbonTabs("id_TabTools").RibbonPanels.Add( _
                   "ADN Tab", "id_ADNTab", clientId)
            End Try

 

Thank you both for all your help!

Message 10 of 11
saseendrankombath
in reply to: Anonymous

It doesn’t matter whether you put the code in single line or split with declarations. It matters where you write the code. The declaration (dim) statement should be outside (before) the “try” block then only it will be taken by the code under “catch” block.

Message 11 of 11
VdVeek
in reply to: saseendrankombath

Is the order in which Add-In is loading first determinative in which order the buttons will show up in the Ribbon panel?

Rob.

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.

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

Post to forums  

Autodesk Design & Make Report