1. Background
After writing several tools for Reivt, for myself, I can use it by coding, but to make it more friendly for other users, we need to make a UI for the fuctions.On revit, it is quite easy to make ribbon.
This part is easy, quite similar as the AutoCAD API, I have written the comments inside the code.
2. Full CODE
[Transaction(TransactionMode.Manual)]
public class ReNumberTab : IExternalApplication
{
public Result OnShutdown(UIControlledApplication application)
{
return Result.Succeeded;
}
public Result OnStartup(UIControlledApplication application)
{
//create a Ribbon Tab
application.CreateRibbonTab("FYTab");//New Tab
//create UIPanel in the Ribbon Tab
RibbonPanel rp = application.CreateRibbonPanel("FYTab", "ReNumber");
//route of assemble
string assemblePath = Assembly.GetExecutingAssembly().Location;
//name space and class name of the function
string classNameReNumberWindow = "ReNumber.ReNumberWindows";
//4. Create push button
PushButtonData pbd = new PushButtonData("ReNameWindows", "ReNameWindows", assemblePath, classNameReNumberWindow);
PushButton pushButton = rp.AddItem(pbd) as PushButton;
// big icon 32px. small icon at 16px
string imgPath = @"C:\ProgramData\Autodesk\Revit\Addins\2019\ReNumberWindows\sheep.png";
//new Uri("pack://application:,,,/ReNumber;component/pic/sheep.png", UriKind.Absolute)
//to set the button image to the button object
pushButton.LargeImage = new BitmapImage(new Uri(imgPath));
//to set the reminder when the mouse float on the button
pushButton.ToolTip = "Renumber all the Windows from \"EW-01\"";
return Result.Succeeded;
}
}
3. Final Result

4. Reference
http://help.autodesk.com/view/RVT/2019/ENU/?guid=Revit_API_Revit_API_Developers_Guide_html