Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

find ribbon tabs and or panels and delete

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
4170 Views, 11 Replies

find ribbon tabs and or panels and delete

I would like to find and delete a ribbon tab.  I have seen some references to Autodesk.Windows, which look like they might help, but also some comments that it is not supported.  Is there a problem using this library?

 

Is there a reasonable way to find a tab and delete it if it exists.

 

I don't seem to have any trouble using getribbonpanels to find the panels on a tab (if it exists), but I can't see an obvious way to delete either the tab or the panels, or in fact the items on a panel.

 

What I would like to do is replace an existing tab/panel with a new one.  So, if I could just wipe out all the items and put in new ones, that would be ok also.

 

Any thoughts?

 

 

11 REPLIES 11
Message 2 of 12
Revitalizer
in reply to: Anonymous

Hi,

 

you can make tabs invisible:

 

private void DisableTab(string name)
{
    foreach (Autodesk.Windows.RibbonTab tab in Autodesk.Windows.ComponentManager.Ribbon.Tabs)
    {
        if (tab.Title==name)
        {
            tab.IsVisible = false;
        }
    }
}

 

Call it when view changes:


private void Application_ViewActivated(object sender, ViewActivatedEventArgs e)
{
    DisableTab("Architecture");
}

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 3 of 12
Anonymous
in reply to: Anonymous

Adwindows.dll is fine don't be scared to use it. There's a trick I found where you can create normal api panels or buttons and then copy them to any other tab / panel. So you should be able to achieve your goal. I've also recently figured out how to use adwindows.dll to create my own context ribbon that works like the modify tab.
Message 4 of 12
jeremytammik
in reply to: Anonymous

Dear Abba,

 

Thank you for your query, and thanks to Revitalizer and Scott for their helpful and thorough answers.

 

I agree with both.

 

Here is another possibility to hide and display a ribbon tab using the official Revit API:

 

http://thebuildingcoder.typepad.com/blog/2013/07/dynamically-hide-and-display-a-ribbon-panel.html

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 12
Anonymous
in reply to: jeremytammik

In case someone finds this useful, I will give a brief, somewhat frustrated account of what I have found.

 

1. I am trying to have a methodology where I can develop routines/interfaces and test without repeatedly restarting revit.

2. To do this, I have found the 'add-in manager' works pretty well.

3. Each time I 're-run' a command from the add-in manager, it creates a new .dll in a temp folder (with a unique name).

4. I have a routine that builds ribbon panels/buttons and links them to command functions, by specifying the DLL and command name.

5. The next time I re-run a command, add-in manager makes a new (different) copy of the dll, which is now different from the dll connected to the ribbon button.

 

I tested this by having the command print out the name of the 'calling' and/or 'executing' dll.  At this point running the command from the button shows one .dll name, and running it directly from the add-in manager shows a different name.  This was unwelcome, but at least seemed logical - each one is running the .dll that was 'current' at the time the 'invoker' was created.

 

6. So I figured that I need to re-build the button, so that it links to the latest (temp) version of the .dll.  But I could not do this since the button already exists.  Renaming the button/panel, etc did not seem to let me recreate it.  So I figured, I had to delete the button and make a new one, which would be linked to the 'latest' .dll.  That was the reason for the query about deleting ribbon elements.

 

Now here is where it gets wierd:

 

When it seemed imposisble to delete panels/buttons, but easy to hide them, I figured I would just keep creating a new panel with its own name each time I reload the command.  (e.g. make panel0 the first time.  Next time, make panel1 and hide panel0.  etc.)  My expectation was that each of these buttons would be linked to its own version of the dll, and the one that is visible would be linked to the latest 'temp' dll created by the add-in manager.

(Keep in mind this was not meant as a final solution but an experiment to figure out what is going on!)

 

When I did this, I found that **all** the  buttons seemed to run the very first .dll, and the add-in manager ran the latest one.  This seemed odd. Just to make sure each button really was what I expected, I put a different name on each button (which reflected the temp folder name based).  So now, each button shows the name of the 'version' that was current when the button was created and linked to the dll.

 

The odd thing is that even though the buttons show different titles, they all seem to run the same .dll.  And it is not the 'current' one that is run from the add-in manager.

 

 

So at that point, I have concluded that I don't understand how the buttons are linked to the routines they invoke.  I have pretty much given up on trying to do ribbon-building with the add-in manager.  I will just re-run individual commands from the add-in manager, and go back to building the ribbon with the 'startup' of the application.  The ribbon will then get obsolete while using the add-in manager, but will be fine for users when things are loaded in the normal way (from .addin manifests).

 

You may think I have lost my mind in doing all this,  but I am expecting to be debugging things on some large models and I really want to be able to work on things without restarting Revit.

 

It generally bugs me when I don't understand what is going on. This crazy exploration has not really helped.  For the moment, I have given up on this.

 

If anybody can explain how the .dll is linked to the button, or how it is found when you click the button, I would love to know. ( I suspect there is probably some kind of 'search')

 

Sorry for writing such a long-winded explanation of this, but I get the feeling that some people are still looking for a nice environment for editting revit programs without restarting all the time.  And hopefully, with the ability to manipulate ribbon panels in the process.

 

In case this long post discourages others from reply to my posts - I promise to keep things brief in the future.

 

Abba

 

Message 6 of 12
ankofl
in reply to: Anonymous

Dear @jeremytammik !

Is there currently (Revit 2025) an option to dynamically delete "PushButtonData" from the "RibbonPanel", or maybe hide it so that the new button links to the new dll? By the way, is it possible to create a "PushButtonData" from a dll located in the resources of another dll? And is it generally required that at the time of creation or registration in the panel (before it is clicked and called), the dll meets all the conditions (class name, location,
etc.), or can it already be solved at the time of the call?

Message 7 of 12
Chuong.Ho
in reply to: Anonymous

I hope this post is make sence to you, some issue with Private Dictionary to store RibbonItemDictionary, you need do some trick to remove panel. :
https://chuongmep.com/posts/2024-04-19-reload-ribbon-revit.html#remove-panel

Chuong Ho

EESignature

Message 8 of 12
ankofl
in reply to: Chuong.Ho

Incredible job! Thank you very much! Added to bookmarks

Message 9 of 12
ankofl
in reply to: Chuong.Ho

Hi @Chuong.Ho !

If it possible to ask, tell us if we can get the name of the button, its description, or some kind of indicator after clicking it?

For example, I created one class MyCommand : IExternalCommand and registered it for several "PushButtonData" ("MyButtonOne", "MyButtonTwo"). After clicking on the button both times through the debugger, I will get to the same Execute() method of the MyCommand class.

In this case, is it possible to determine which of the buttons called this method? Any way, even the most perverted

Thanks!

Message 10 of 12
Chuong.Ho
in reply to: ankofl

You can do it with some step like this :

1. Add assembly reference AdWindows.dll

2. Add a event tracking user click to the button at IExternalApplication when user click to any button

 

 

using AW = Autodesk.Windows;
Autodesk.Windows.ComponentManager.UIElementActivated += RibbonUtils.ComponentManagerOnUIElementActivated;

public static void ComponentManagerOnUIElementActivated(object sender, AW.UIElementActivatedEventArgs e)
        {
            try
            {
                var id = e.Item.Id;
                // match with id string contents here and set to some where, after thatm match with all command exist in your plugin
        }

3. Call the action from external command match with id return from the event clicked

 

Chuong Ho

EESignature

Message 11 of 12
ankofl
in reply to: Chuong.Ho

Thank you so much for the prompt response!

I think this is exactly what I need!

Message 12 of 12
ankofl
in reply to: Chuong.Ho

e.Item will be null if TabPanel is selected

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Rail Community