Quick Links - Also see the menu above and more choices on the right side of the blog (too much, but all good stuff)

\/ ...and now BIMbuilder.com Blog Posts... \/

Thursday, December 24, 2009

Revit Tech Tip – Ribbons,tabs and Panels

On the very technical side, Bold out of the Red came up with a great post for those of you daring enough to mess with the guts of Revit.

Repost: http://redbolts.com/blog/post/2009/12/21/Merry-Christmas-e28093-Ribbonstabs-and-Panels.aspx

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…

Source: Merry Christmas – Ribbons,tabs and Panels


0 comments:

  © Blogger template ProBlogger Template by Ourblogtemplates.com 2008

Back to TOP  

[Valid Atom 1.0]