ricaun.AutoCAD.UI provides a set of UI controls and utilities for AutoCAD .NET applications, built on top of the AutoCAD.NET library. It is designed to simplify the development of ribbon user interfaces in AutoCAD plugins.
The ExtensionApplication class provides a base implementation for AutoCAD .NET applications to start and shutdown, managing the ribbon control lifecycle.
using ricaun.AutoCAD.UI;
using Autodesk.AutoCAD.Runtime;
[assembly: ExtensionApplication(MyExtensionApp)]
public class MyExtensionApp : ExtensionApplication
{
public override void OnStartup(RibbonControl ribbonControl)
{
ribbonControl.CreatePanel("MyPanel");
}
public override void OnShutdown(RibbonControl ribbonControl)
{
ribbonControl.RemovePanel("MyPanel");
}
}The RibbonExtension class offers extension methods to create and manage ribbon panels, buttons, and other UI elements in AutoCAD.
using ricaun.AutoCAD.UI;
using Autodesk.AutoCAD.Runtime;
[assembly: ExtensionApplication(MyExtensionApp)]
public class MyExtensionApp : ExtensionApplication
{
public override void OnStartup(RibbonControl ribbonControl)
{
var ribbonPanel = ribbonControl.CreatePanel("MyPanel");
ribbonPanel.CreateButton("MyButton")
.SetText("Click Me")
.SetDescription("This is a button description")
.SetToolTip("This is a button tooltip")
.SetImage("Resources/image16-light.png")
.SetLargeImage("Resources/image32-light.png")
.SetCommand(() =>
{
// Button click logic here
});
}
public override void OnShutdown(RibbonControl ribbonControl)
{
ribbonControl.RemovePanel("MyPanel");
}
}The SetImage and SetLargeImage methods automatically handle theme changes based in the key name light and dark in the image file names.
ribbonPanel.CreateButton("MyButton")
.SetImage("Resources/image16-light.png") // If the theme is dark, it will use "Resources/image16-dark.png" internally
.SetLargeImage("Resources/image32-light.png"); // If the theme is dark, it will use "Resources/image32-dark.png" internallyWhen the AutoCAD theme changes, the ribbon button images will automatically update to match the current theme.
This project is licensed under the MIT License.
Do you like this project? Please star this project on GitHub!
