Adding Non-Commands to the Revit Ribbon

In between all the hullabaloo about the new version of Revit, here is some news dealing with the old one and the

Revit Python shell

implemented by Daren Thomas.
Daren now found a way to add new items such as command buttons to a Revit ribbon panel without actually having any real underlying external command implementation to hook them up to.
He uses Reflection.Emit to simulate the missing IExternalCommand implementation.
Here is Daren’s own description:

I just published a post on a technique for

adding IronPython scripts as commands to a Revit ribbon panel
.
I’m not sure if this technique could be used for other purposes, as it mainly allows dynamically created commands to be accessible by Revit, but you never know…

The technique uses Reflection.Emit to create types that subclasses IExternalCommand with an instance field set to a different value for each type in the parameterless constructor.
These types are added to a dynamic assembly, stored to disk and can then be instantiated by Revit in the usual fashion.

Thought you might be interested…

P.S.: This still doesn’t solve the problem of dynamically adding commands after IExternalApplication.OnStartup to the Ribbon, but it’s a start…

P.P.S. from Jeremy on the topic of

dynamically reloading and debugging Revit add-ins
and the

AddInManager
, which takes us back to the hullabaloo around the new release:
if you are interested in either of these two topics, you really must check out the new 2011 version of the Add-In Manager… it provides a solution! More on that soon…


Comments

2 responses to “Adding Non-Commands to the Revit Ribbon”

  1. Hi Jeremy, thanks for this post.
    I understand this post is from 2010, so I’m hoping for some new news. Specifically in regards to your first “P.S.” — is it now possible to dynamically add an element to the Ribbon Panel after IExternalApplication.OnStartup has already executed?

  2. Dear Muers,
    Thank you for your appreciation.
    I have lots of news on this topic for you.
    I will only mention the two most recent additions.
    The first discusses the exact same topic as above, which I would assume not to be of that much real-world interest:
    http://thebuildingcoder.typepad.com/blog/2014/06/room-editor-live-and-unofficial-custom-ribbon-button.html#4
    The second takes the issue much further to the more useful case of adding a real Revit external command button anywhere you like in the ribbon, at any time:
    http://thebuildingcoder.typepad.com/blog/2014/07/moving-an-external-command-button-within-the-ribbon.html
    The button creation uses standard Revit API functionality, and then the .NET ribbon functionality is used to move it to a different location.
    The .NET part can be activated any time you like. The Revit API ribbon creation maybe not… try it out and let us know. Thank you.
    Cheers, Jeremy.

Leave a Reply to MuersCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading