Skip to content

bezawy/Ribbons

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.


🚀 Features

  • 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, and ToggleButton.
  • 📏 Flexible Layouts: Shows RowStackedItems, FlowStackedItems, and RowLargeStackedItems.
  • 🖼️ 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.

🧠 Code Breakdown

This add-in's main purpose is to show the power of the ricaun.Revit.UI library for simplifying ribbon creation.

1️⃣ The Standard (Verbose) Way

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.


2️⃣ The Fluent Way (with ricaun.Revit.UI)

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!).


3️⃣ Stacking & Layouts

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);

4️⃣ Creating a Pulldown Button

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(...);

5️⃣ Creating a Split Button

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");

🛠 Installation

  1. Clone the repo or download the .zip.
  2. Open the project in Visual Studio.
  3. Important: Install the ricaun.Revit.UI NuGet package.
  4. Build the project.
  5. Copy the compiled .dll, .addin file, and any other dependencies to: C:\Users\YOUR_USERNAME\AppData\Roaming\Autodesk\Revit\Addins\20XX

📁 Folder Structure

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

🔗 Contributing

Found a bug or want to demonstrate another button type? Fork the repo, make changes, and submit a pull request — contributions are welcome!


📜 License

Released under the MIT License


🙌 Credits

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>

About

IExternalApplications for Ribbons of Revvit API - Open Source

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages