Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
antunbrnic222
389 Views, 4 Replies

Adding a Command to Customize->Ribbon

Hello,

How do I add a button hereimage.png

 

According to ChatGPT this code should work but "CustomizationManager" is not recognized

 

 

 

Private Sub AddToCustomization(btnDef As ButtonDefinition)
    ' Get the customization manager.
    Dim customizationMgr As CustomizationManager = g_inventorApplication.CommandManager.CustomizationManager

    ' Show the Customize dialog to allow users to customize the ribbon.
    customizationMgr.EditCustomize()

    ' Note: The EditCustomize() method will open the Customize dialog, allowing users to add the button to any ribbon or toolbar they choose.
    ' Users can drag and drop the button from the "Commands" list to the desired ribbon tab or panel.
End Sub

 

 

 

 

But only thing i managed to do is this sample that is hardcoded

image.png

 

With this code

 

 

"User interface definition"
        ' Sub where the user-interface creation is done.  This is called when
        ' the add-in loaded and also if the user interface is reset.
        Private Sub AddToUserInterface()
            ' This is where you'll add code to add buttons to the ribbon.

            '** Sample to illustrate creating a button on a new panel of the Tools tab of the Part ribbon.

            '' Get the part ribbon.
            Dim partRibbon As Ribbon = g_inventorApplication.UserInterfaceManager.Ribbons.Item("Part")

            '' Get the "Tools" tab.
            Dim toolsTab As RibbonTab = partRibbon.RibbonTabs.Item("id_TabTools")

            '' Create a new panel.
            Dim customPanel As RibbonPanel = toolsTab.RibbonPanels.Add("Sample", "MysSample", AddInClientID)

            '' Add a button.
            customPanel.CommandControls.AddButton(m_sampleButton)
        End Sub