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: 

Change Button's Tab/Panel Position

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
yildiz.emrullah
340 Views, 5 Replies

Change Button's Tab/Panel Position

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? 

5 REPLIES 5
Message 2 of 6

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
Message 3 of 6

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.
Message 4 of 6
ricaun
in reply to: yildiz.emrullah

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

Message 5 of 6
yildiz.emrullah
in reply to: ricaun

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

Message 6 of 6
ricaun
in reply to: yildiz.emrullah

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

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

Post to forums  

Autodesk Design & Make Report