Modify Built-In Ribbon

By Xiaodong Liang

Question:
I wanted to modify the title of the buinlt-in ribbon tab and panel, such as [Tool Add-ins 1], [Tool Add-ins 2], [Tool Add-ins 3].

Solution
Navisworks also uses the same library to present a Ribbon: AdWindows.dll
This provides a public API under the namespace Autodesk.Windows

Here is the examples of using it inside

Revit:
http://thebuildingcoder.typepad.com/blog/2011/02/pimp-my-autocad-or-revit-ribbon.html

Inventor:
http://adndevblog.typepad.com/manufacturing/2014/01/modify-ribbon-and-menu-items.html

but it’s not a officially supported approach. And some functions like adding a command button to the Ribbon are not supported. So we cannot guarantee the behaviors. When using it, take care and make sure that everything is working as expected.

For the question to modify title of the built-in ribbon tab and panel, the code snippet would be:

public void modifyRibbon()

{

    RibbonTabCollection oTabs = Autodesk.Windows.ComponentManager.Ribbon.Tabs;

    RibbonTab oCloneTab = null;

    foreach(RibbonTab oTab in oTabs)

   
{
 

        if (oTab.Title == "Tool Add-ins 1")

        {                

            oTab.Title = "MyTab1"; 

            RibbonPanelCollection oPanels =
                                    oTab.Panels;

              

            foreach (RibbonPanel oRP in oPanels)

            {

                if (oRP.Source.Title ==
                            
"Tool Add-ins 1"
)

                {

                    oRP.Source.Title =
                             "MyTab1_Panel1"
;

                    break;

                }

            }

            break; 

        }            

    }

}

image


Comments

4 responses to “Modify Built-In Ribbon”

  1. Aaron Avatar
    Aaron

    Where should this function be put in so it could be triggered when NW is open?

  2. Sameeksha Avatar
    Sameeksha

    I believe the function should be:
    protected override void OnLoaded()
    {
    ModifyRibbon();
    }
    OnLoaded is a virtual function of Plugin and gets executed for each plugin when it is loaded.

  3. just tested, seems not working, any clue?
    System.NullReferenceException: ‘Object reference not set to an instance of an object.’
    Autodesk.Windows.ComponentManager.Ribbon.get returned null.

Leave a Reply to joeCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading