How to hide ribbon tabs on events of application.

How to hide ribbon tabs on events of application.

Anonymous
Not applicable
1,022 Views
2 Replies
Message 1 of 3

How to hide ribbon tabs on events of application.

Anonymous
Not applicable

I want to hide some ribbon tabs when loading the revit application. Don't hide them by clicking a command.

 

Running IExternalApplication on revit 2021 is invalid code:

 

var tabs = ComponentManager.Ribbon.Tabs.ToList();

foreach (var tab in tabs)
{
  tab.IsVisible = false;
  break;
}

 

 

 

注意:Revit 2021。

0 Likes
Accepted solutions (1)
1,023 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni

You may very well encounter difficulties trying to achieve what you describe, because, as far as I know, Revit itself actively hides and displays ribbon tabs under certain circumstances. So, regardless of what you do to try to hide and display them yourself, Revit will very probably come along and undo your efforts. 

 

In general, Revit has a pretty clear idea of what it wants and does not want to happen in the user interface.

 

Trying to interfere with the built-in UI paradigm is probably tricky and error prone.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

When first reading revit document, it seems that [analysis] tab is visible. If close it and open this, it seems that all tabs are visible or not visible. I cannot fix the problem and I want to record gif to your team. But, The English version of the program crashed two times(sended error report).

 

I usually use Chinese version of Revit.

 

 

protected override void OnStartup(UIControlledApplication application)
{
  application.ControlledApplication.ApplicationInitialized += HideMenu;
  application.ControlledApplication.DocumentOpened += HideMenu;
}

private void HideMenu(object sender, Autodesk.Revit.DB.Events.DocumentOpeningEventArgs e)
{
  var tabs = ComponentManager.Ribbon.Tabs.ToList();

  foreach (var tab in tabs)
  {
     if (tab.KeyTip == "A")
       continue;
                
     tab.IsVisible = false;
  }
}

 

 

 

 

0 Likes