Search code examples
c#apiribbonautodeskrevit

Revit C#: Copy existing button to my Ribbon


I want to use the Create-Wall-Button from Architecture in my Ribbon. I've tried debugging and found the splitbutton here: Autodesk.Windows.ComponentManager.Ribbon.Tabs[0].Panels[1].Source.Items[0]

How can I copy this SplitButton to my Ribbon or what I have to call in a new Button to use this function?

Thank you.


Solution

  • It is posible to clone an built-in command button and add it to another tab, however you would need a couple of tricks and of course the non-supported Autodesk.Windows dll.

    I think what you are looking for is the method PostCommand from the UIApplication. Just create a new command and the requested Postable Command will be executed after your own command is completed:

    var app = cmdData.Application;
    var cmdId = RevitCommandId.LookupPostableCommandId(PostableCommand.StructuralWall);
    app.PostCommand(cmdId);