It's not a good idea to change/add buttons on the fly.
But...
On the OnStartup you could save the UIControlledApplication and get using static on some command to control the adding/removing panels buttons and stuff.
using Autodesk.Revit.UI;
class App : IExternalApplication
{
public static UIControlledApplication UIControlledApplication()
{
return app;
}
private static UIControlledApplication app;
public Result OnStartup(UIControlledApplication application)
{
app = application;
return Result.Succeeded;
}
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
}
Using this on some command/service.
var application = App.UIControlledApplication();
One problem to add some buttons on the fly:
- Revit does not add the button on the shortcut.
A better approach is to add the button on the start and hide the button and only show when needed.
See yaa!