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

Adding a Command to Customize->Ribbon

antunbrnic222
Explorer

Adding a Command to Customize->Ribbon

antunbrnic222
Explorer
Explorer

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

 

 

 

 

0 Likes
Reply
Accepted solutions (1)
389 Views
4 Replies
Replies (4)

Michael.Navara
Advisor
Advisor
Accepted solution

Please use standard Inventor API reference and samples instead of ChatGPT.

Here is the link how to customize ribbon in Inventor.

antunbrnic222
Explorer
Explorer

Thanks for the reply, I did follow it but this is not what I need, this still hardcodes it to some "TAB".

I want it as a button in Customize->Ribbon so I can later add it where I want it.

0 Likes

kresh.bell
Collaborator
Collaborator
0 Likes

antunbrnic222
Explorer
Explorer

I managed to get it to work, the problem was that I didn't specify images for button and that is the reason why i wasn't in customize tab :sad_but_relieved_face:

 

m_sampleButton = controlDefs.AddButtonDefinition("Sastavnica", "Sastavnica", CommandTypesEnum.kShapeEditCmdType, AddInClientID,,, smallIcon, largeIcon)

smallIcon,largeIcon 

0 Likes