Here's a complete README file generated for your project, based on the structure of the example you provided and the C# code for your IExternalApplication.
- ✨ Fluent Builder: Chain methods like
.SetText(),.SetToolTip(), and.SetLargeImage()for clean code. - 🗂️ Multiple Panels: Creates three distinct panels: "Detail", "Toggles", and "Utils".
- 🔘 Button Variety: Demos
PushButton,PulldownButton,SplitButton, andToggleButton. - 📏 Flexible Layouts: Shows
RowStackedItems,FlowStackedItems, andRowLargeStackedItems. - 🖼️ Embedded Icons: Uses
pack://URIs to load icons directly from embedded project resources. - 🧼 Clean Code: Drastically simplifies ribbon creation compared to the standard, verbose Revit API.
This add-in's main purpose is to show the power of the ricaun.Revit.UI library for simplifying ribbon creation.
Before, creating a single button was multi-step, error-prone, and hard to read:
/*
//Create a new ribbon tab
string folderPath = @"C:\temp";
string dll = Path.Combine(folderPath, "App.dll");
string myRibbon = "HomeII";
application.CreateRibbonTab(myRibbon);
RibbonPanel panelA = application.CreateRibbonPanel(myRibbon, "A");
PushButton btnOne = (PushButton)panelA.AddItem(new PushButtonData("One", "One", dll, "AGECS.One"));
btnOne.LargeImage = new BitmapImage(new Uri(Path.Combine(folderPath, "image32-1.png"), UriKind.Relative));
btnOne.Image = new BitmapImage(new Uri(Path.Combine(folderPath, "image16-1.png"), UriKind.Relative));
btnOne.ToolTipImage = new BitmapImage(new Uri(Path.Combine(folderPath, "thumbs.jpg"), UriKind.Relative));
btnOne.ToolTip = "Button one Tool Tip";
btnOne.LongDescription = "This command is great , It's really great . Really really Wonderful!";
*/➡️ Problem: Hard-coded paths, lots of boilerplate, and properties set one by one.
Now, we can create a fully-configured button in a single, readable statement.
// Button One
var btnOne = panelA.CreatePushButton<Class1>("One")
.SetText("HomeIIFaces")
.SetToolTip("Button Two Tool Tip").SetLongDescription("This Command is great, It's really great.")
.SetImage(new BitmapImage(new Uri("pack://application:,,,/Pushbutton;component/Resources/icon_16_3.ico")))
.SetLargeImage(new BitmapImage(new Uri("pack://application:,,,/Pushbutton;component/Resources/icon_48_13.ico")))
.SetToolTipImage(new BitmapImage(new Uri("pack://application:,,,/Pushbutton;component/Resources/icon_48_24.ico")));➡️ Solution: Method chaining is clean, readable, and uses embedded resources (no loose icon files!).
The library makes complex panel layouts simple.
// Stack two small buttons vertically
panelA.RowStackedItems(btnOne, btnTwo);
// Stack three large buttons horizontally, which wrap if the panel is too small
panelB.FlowStackedItems(btnImport, btnExport, btnSync);
// Stack four large buttons horizontally (no wrap)
panelB.RowLargeStackedItems(btnCr, btnCr2, btnCr3, btnCr4);Define the buttons first, then add them to the pulldown.
var PulldownData = new[]
{
panelB.NewPushButtonData<Class1>("CreateExtrusion")
.SetText("CreateExtrusion")
.SetLargeImage(...),
panelB.NewPushButtonData<Class1>("LoadFamily")
.SetText("LoadFamily")
.SetLargeImage(...),
};
/// pulldownButton
panelB.CreatePulldownButton(PulldownData)
.SetText("Families")
.SetLargeImage(...);Similarly, define a list of buttons (often ToggleButtonData) and create the split button.
var splitButtonData = new[]
{
panelB.NewToggleButtonData<Class1>("RetrieveInfoOriginal")
.SetText("RetrieveInfoOriginal")
.SetLargeImage(...),
panelB.NewToggleButtonData<Class1>("syncviews")
.SetText("Sync views")
.SetLargeImage(...),
};
panelB.CreateSplitButton(splitButtonData)
.SetText("Toggles")
.SetToolTip("Toggle Options");- Clone the repo or download the
.zip. - Open the project in Visual Studio.
- Important: Install the
ricaun.Revit.UINuGet package. - Build the project.
- Copy the compiled
.dll,.addinfile, and any other dependencies to:C:\Users\YOUR_USERNAME\AppData\Roaming\Autodesk\Revit\Addins\20XX
HomeII/
│
├── src/
│ ├── App.cs # IExternalApplication (Ribbon setup)
│ └── Commands/
│ └── Class1.cs # IExternalCommand (Button logic)
├── Resources/ # Embedded icons (Set to "Embedded Resource")
│ ├── ico_48_13.ico
│ ├── icon_16_3.ico
│ └── ...
└── README.md
Found a bug or want to demonstrate another button type? Fork the repo, make changes, and submit a pull request — contributions are welcome!
Released under the MIT License
Built with ❤️ using C# and the Revit API.
Special thanks to ricaun for the powerful and time-saving ricaun.Revit.UI library.
<div align="center"> ✨ Stop fighting the API and start building beautiful ribbons! ✨ </div>