Adding contextual buttons to the ribbon

Adding contextual buttons to the ribbon

Anonymous
Not applicable
1,815 Views
4 Replies
Message 1 of 5

Adding contextual buttons to the ribbon

Anonymous
Not applicable

Hey, I'm slowly getting up to speed with using the API and writing add-ins for Revit. I'd like to be able to add contextual buttons to the ribbon - is this possible? (I already know how to add tabs, panels and buttons at startup)

 

For example, when you are working with the standard Revit user interface and you select an element, the Modify ribbon tab turns green, and some additional buttons appear (depending on the type of element you selected). For some elements, a whole new tab can also appear.

 

I'd like to offer different sets of controls at different stages during the execution of my ExternalCommand. These will offer the user some settings which control the behaviour of certain operations. I can achieve a similar effect currently, by using different Windows Forms that Show() at the appropriate moments, and Close() or Hide() when not needed, but it doesn't feel like an ideal solution.

 

Thanks in advance.

 

 

0 Likes
Accepted solutions (1)
1,816 Views
4 Replies
Replies (4)
Message 2 of 5

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Tom,

 

The Revit Ribbon API is rather restricting and does not offer what you are asking for out of the box.

 

You can control part of the button functionality using a command availability class implementing the IExternalCommandAvailability interface.

 

You can also switch the command button text or images.

 

Here are some samples:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.26

 

If you need the kind of flexibility you have already implemented using Windows Forms, you should probably stick with those.

 

Cheers,

 

Jeremy



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

Message 3 of 5

Anonymous
Not applicable

Thanks for your help Jeremy. If I understand you correctly, this would mean adding all the buttons to the ribbon on startup, and disabling them when they are not needed?

 

That would work, so many thanks for the suggestion, and the samples. I'll have a think about it, but I suspect that (as you suggest) using Windows Forms may be better in my application. They provide a lot more flexibility, and also potentially have the effect of bringing the existence of these optional settings to the user's attention, when they are available.

 

Many thanks again.

 

 

0 Likes
Message 4 of 5

jeremytammik
Autodesk
Autodesk

Thank you for your appreciation.

 

Yes, that is what I mean.

 

Note that disabled buttons remain visible, they are just greyed out...

 

Cheers,

 

Jeremy



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

0 Likes
Message 5 of 5

Anonymous
Not applicable

Hi,

I am a very new beginner in Revit. I have gotten a trouble about the ribbon menu. In the ribbon area, in architecture and tructure button, when you click on them. The all button have been not highlighted as they should. They did Before. I do not know if you can help me to loose it. Thank you in advance,

Best Regards,

Hai,

0 Likes