Happy New Year – Custom Ribbon Tabs Complete

by Guy Robinson 8. January 2010 13:30

As anyone who tried the Christmas ribbon solution would have found, it lacked one feature. The ability to handle context switching between standard projects and families. Changing to the other project type would cause the custom ribbon tab to disappear. There are a number of approaches to handling this context switching.

Brian left a comment on the original post and others contacted me privately to highlight the problem and ask how it can be solved. To make it easier for people I’ve updated the RibbonService class to automatically handle the context switching as per standard behaviour. Hopefully this will also help those coding a more customised solution.

Using the updated RibbonService requires one additional line to bind Revit’s ControlledApplication object to the RibbonService as follows:

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

Note I updated the namespaces so you’ll have to update your Revit.ini accordingly.Source and binary can be downloaded here . Enjoy!!

Tags:

Ribbon | RevitAPI

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.