Ribbon Panel Caption Button

Ribbon Panel Caption Button

Zoltan.Ferenczy
Explorer Explorer
1,501 Views
7 Replies
Message 1 of 8

Ribbon Panel Caption Button

Zoltan.Ferenczy
Explorer
Explorer

Is it possible to create a caption button on a custom ribbon panel? The caption button is the little arrow in the corner that usually opens a settings dialog related to the commands on the panel. I don't see any way to do it through the API.

 

Caption.png

0 Likes
Accepted solutions (1)
1,502 Views
7 Replies
Replies (7)
Message 2 of 8

Kennan.Chen
Advocate
Advocate
Accepted solution

You can make use of some APIs defined in AdWindows.dll which you can easily find in Revit root folder.

 

Everything starts from getting the RibbonControl instance by calling Autodesk.Revit.Windows.ComponentManager.Ribbon property. 

 

You need to create the RibbonTab and RibbonPanel in AdWindows way, then organize then in the RibbonControl instance.

 

When the RibbonPanel is created, you can set a RibbonButton to RibbonPanel.Source.DialogLauncher property to create the caption button. The RibbonButton will respond to UI click event by calling its CommandHandler command.

 

That's it!

0 Likes
Message 3 of 8

Zoltan.Ferenczy
Explorer
Explorer

In The CommandHandler of buttons created using the AdWindows API, how does one get access to the ExternalCommandData in the ICommnand implementation? Or, How does one call an IExternalCommand's Execute method?

 

Buttons created in this way are not like buttons created with the Autodesk.Revit.UI classes.

0 Likes
Message 4 of 8

Kennan.Chen
Advocate
Advocate

Simply pass the Application object via constructor

0 Likes
Message 5 of 8

Kennan.Chen
Advocate
Advocate

If you create a RibbonButton in AdWindows way(WPF way more specifically), you gain much more freedom to manipulate the Button. A RibbonButton provides a CommandHandler property. You can assign an instance implementing ICommand interface to that property, which will enable the RibbonButton to react to the UI click event. In that ICommand implementation, you can raise a predefinded ExternalEvent to run Revit API code. Alternatively you can adopt Revit.Async library to run Revit API directly. You can access this library on nuget or source code on github.com.

0 Likes
Message 6 of 8

PYTHINKS
Participant
Participant

Hello ! Can you give me a sample code?

0 Likes
Message 7 of 8

ricaun
Advisor
Advisor

I add that in my ricaun.Revit.UI library:

 

Autodesk.Revit.UI.PushButton pushButton;
ribbonPanel.SetDialogLauncher(pushButton);

 

Here is video about that:

 

 

See yaa

 

 

Luiz Henrique Cassettari

ricaun.com - Revit API Developer

AppLoader EasyConduit WireInConduit ConduitMaterial CircuitName ElectricalUtils

0 Likes
Message 8 of 8

PYTHINKS
Participant
Participant

Thanks Ricaun, it helped me

0 Likes