Merry Christmas – Ribbons,tabs and Panels

by Guy Robinson 21. December 2009 14:53

It’s that time of the year, so why not finish with a post on what has probably been the most controversial aspect of the Revit 2010 release, the ribbon. In general I’ve stayed clear of UI customisation because I’d prefer Autodesk get it right. However, for API users the ability to add a tab for their own commands has been on the wishlist since the ribbon went live. Jeremy talked about it here with the limitation you couldn’t run API commands.

Using a little smoke and mirrors it is possible however to run API commands. The key is creating a Revit ribbon panel not a base Autodesk panel. This then allows you to use all the standard constructs for creating buttons and therefore running API commands when the button is clicked.

Merry Christmas

The code is very similar to creating buttons using the standard API’s.

public IExternalApplication.Result OnStartup(ControlledApplication application)
        {
            try
            {
                // Create User tab and get a revit panel
                var tab = RibbonService.CreateTab("RED_ID", "Merry Christmas", true);
                var panel = RibbonService.CreatePanel(tab, "Presents");
                ...

RibbonService.CreateTab(…) creates your custom tab. You then add a Revit panel to this tab using RibbonService.CreatePanel(…) . Once you have the panel you can add buttons as per the standard API.

Although this is using standard API’s and has been reliable for sometime now, in publishing this code I need to add the standard disclaimers:

If it crashes/ corrupts your projects it’s not my fault.

If you have problems using this code don’t expect Autodesk to support it.

If it causes your computer to catch fire, it’s not my fault.

If it causes your partner to attack your car with a golf club leading to you crashing into a tree, it’s not my fault or anything to do with my code or Autodesk’s ;-)

I’d also add, don’t abuse this. If Autodesk start seeing every person and their dog adding a tab for 1 or 2 commands they’ll have good justification to shut this down. I see this only been used by inhouse developers wanting to create a company tab or 3rd party developers with numerous commands which they want to aggregate on a single tab.

Source and binary here , enjoy!! Merry Christmas and a happy new year. 2010 is going to be a great year to be a Revit user I think…

Tags:

Ribbon | RevitAPI

Comments (3) -

Brian
Brian United States
12/23/2009 2:48:43 AM #

Hi,
I'm new to your blog but I've been looking for something like this for a while.  My office has been searching for ways to customize Revit to our office needs and this seems like something we could use.
I should also tell you that I have little to no programming experience.  I have 1 question and maybe more in the future (if you're willing):
Is there any way to have a bigger button?  For example, your Ferrari icon is so small, is it possible to make it bigger?
Thanks for the help,
Brian

Guy Robinson
Guy Robinson
12/23/2009 4:58:38 AM #

Hi Brian,

Well the icon guidelines in the SDK say 32x32 is recommended. A ferrari is never going to look good at 32x32px Wink If this for internal use though you have no need to stick to the icon guidelines so you can do what you want in theory.

HTH,

Guy

Brian
Brian United States
12/24/2009 12:55:19 AM #

Guy,
It looks as though the image size does not govern the size of the button.  When I make the button bigger (50x50) the button only shows the a portion of the icon (32x32).  
Another thing that I've noticed is that the tab seems to disappear after working in Revit for a while.  Any idea why? Thanks again.
-Brian

Comments are closed

About the Author

A .NET software Developer providing custom applications and commands for architecture firms exclusively working with Autodesk Revit and integration with any associated applications. All from a little place north of Whitianga, New Zealand.

Page List

Disclaimer

I'm self employed so the opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway☺

© Copyright2008

Creative Commons License
Blog content is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.

With the following exception. All code snippets, application and libraries are licensed under a a Apache License Version 2.0

Autodesk Revit®

Autodesk: Revit is a product that is wholly owned by Autodesk. Any reference to Revit,Revit API, Revit Architecture, Revit MEP or Revit Structure on this site is made acknowledging this ownership. Refer to Autodesk's own web site and product pages for specific trademark and copyright information. Autodesk represents a great many products and every attempt will be made to respect their ownership whenever one of these other products is mentioned on this site.