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?
Solved! Go to Solution.
Solved by saseendrankombath. Go to Solution.
Solved by philippe.leefsma. Go to Solution.
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, , )
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.
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.
Hi Thomas,
saseendrankombath is correct, you should use a Try/Catch block to attempt accessing the panel first, before creating it, so you can manage conflicts between two add-ins. The ClientId doesn't really matter when creating a new panel, that's the internal name that is taken into account.
You can read the API Help Files, eventually:
ClientId: Input String that uniquely identifies the client. This is the CLSID of the AddIn in a string form, e.g. "{C9A6C580\-3817\-11D0\-BE4E\-080036E87B02}". If supplied, this string is used at Inventor start up time to determine whether the AddIn that created this ribbon panel has since been uninstalled. If so, the panel is deleted.The string is also used to find all the panels to delete when the associated Add\-in is unloaded. A 'dummy' string or a null string can be specified, but is not recommended.
Regards,
Philippe.
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
Works perfectly on my side, take a look at the attached project ...
Testing under 2014
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)
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!
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.
Is the order in which Add-In is loading first determinative in which order the buttons will show up in the Ribbon panel?
Rob.