Change Button's Tab/Panel Position

yildiz.emrullah
Participant
Participant

Change Button's Tab/Panel Position

yildiz.emrullah
Participant
Participant

Hello,

I am working on an add-in where we would like to allow users to change the button's tab or panel positions as they want within a configurator window that we will be creating. I searched online I saw some article's saying it may not be possible but I wanted to give it a try in this post.

 

https://forums.autodesk.com/t5/revit-api-forum/change-ribbonitem-button-properties-at-runtime/m-p/82...  

My question is if it is doable or not on runtime. Is there any type of button or approach that can achieve this on runtime? 

0 Likes
Reply
Accepted solutions (2)
340 Views
5 Replies
Replies (5)

jeremy_tammik
Autodesk
Autodesk
Accepted solution

I am not aware of any official Revit API support for this. I think that the panel and button orders are determined by their sequence of creation, but that is not officially stated anywhere, afaik, and would need testing. Once that is established, even if unsupported, you might be able to change their order by destroying the previous ones and recreating them afresh in a different order. That all sounds awfully fragile to me.

  

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

yildiz.emrullah
Participant
Participant
Thank you very much for the quick answer! I will be doing some tests and will try to share if I found anything that works for me.
0 Likes

ricaun
Advisor
Advisor
Accepted solution

There is a way to change the order using AdWindows.dll.

 

In the Autodesk.Windows.RibbonPanel and Autodesk.Windows.RibbonTab is possible to change the position of the items using the method Move from ObservableCollection.

 

Here are some simple samples:

Autodesk.Windows.RibbonPanel awRibbonPanel = ribbonPanel.GetRibbonPanel();
awRibbonPanel.Source.Items.Move(0, 1);

Autodesk.Windows.RibbonTab awRibbonTab = ribbonPanel.GetRibbonTab();
awRibbonTab.Panels.Move(0, 1);

I'm using my library ricaun.Revit.UI that has the methods GetRibbonPanel and GetRibbonTab.

 

I never tried to change the order of the Items in the RibbonPanel, but change the order in the Panels order in the RibbonTab I always use to reorder by Title.

 

I hope this helps.

 

See ya!

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes

yildiz.emrullah
Participant
Participant

It looks very helpful Henrique, thank you very much! I will be still looking for other flexibilities.

0 Likes

ricaun
Advisor
Advisor

Panels and Items is a ObservableCollection class, so there are some implementations to make it simpler than using the Move method.

 

I used this as a reference to implement some Extension for OrderBy and others: https://stackoverflow.com/questions/19112922/sort-observablecollectionstring-through-c-sharp

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes