Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions Build/.nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,100 @@
"VSCode"
]
},
"IssConfiguration": {
"type": "object",
"properties": {
"Title": {
"type": [
"null",
"string"
]
},
"Image": {
"type": [
"null",
"string"
]
},
"ImageSmall": {
"type": [
"null",
"string"
]
},
"Icon": {
"type": [
"null",
"string"
]
},
"Licence": {
"type": [
"null",
"string"
]
},
"Language": {
"oneOf": [
{
"type": "null"
},
{
"$ref": "#/definitions/IssLanguage"
}
]
},
"IssLanguageLicences": {
"type": [
"array",
"null"
],
"items": {
"$ref": "#/definitions/IssLanguageLicence"
}
}
}
},
"IssLanguage": {
"type": "object",
"properties": {
"Name": {
"type": [
"null",
"string"
]
},
"MessagesFile": {
"type": [
"null",
"string"
]
}
}
},
"IssLanguageLicence": {
"type": "object",
"properties": {
"Name": {
"type": [
"null",
"string"
]
},
"MessagesFile": {
"type": [
"null",
"string"
]
},
"Licence": {
"type": [
"null",
"string"
]
}
}
},
"ExecutableTarget": {
"type": "string",
"enum": [
Expand All @@ -30,6 +124,7 @@
"GitPreRelease",
"GitRelease",
"Pack",
"PackageBuilder",
"PrePack",
"Release",
"Sign"
Expand Down Expand Up @@ -116,9 +211,21 @@
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"InstallationFiles": {
"type": "string"
},
"IssConfiguration": {
"$ref": "#/definitions/IssConfiguration"
},
"MainName": {
"type": "string"
},
"MiddleVersions": {
"type": "boolean"
},
"NewVersions": {
"type": "boolean"
},
"NuGetApiKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
Expand All @@ -133,12 +240,27 @@
"type": "string"
}
},
"ProjectNameFolder": {
"type": "boolean"
},
"ProjectRemoveTargetFrameworkFolder": {
"type": "boolean"
},
"ProjectVersionFolder": {
"type": "boolean"
},
"ReleaseBundle": {
"type": "boolean"
},
"ReleaseFolder": {
"type": "string"
},
"ReleaseNameVersion": {
"type": "boolean"
},
"ReleasePackageBuilder": {
"type": "boolean"
},
"SignFile": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
Expand Down
3 changes: 2 additions & 1 deletion Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
using ricaun.Nuke;
using ricaun.Nuke.Components;

class Build : NukeBuild, IPublishPack, IPrePack
class Build : NukeBuild, IPublishPack, IAutoCADPackageBuilder, IPrePack
{
string IHazPackageBuilderProject.Name => "Example";
public static int Main() => Execute<Build>(x => x.From<IPublishPack>().Build);
}
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [0.2.0] / 2025-07-04
### Features
- Add `ricaun.AutoCAD.UI.Example` sample project.
### UI
- Add `AddSeparator` extension to create a separator in the ribbon panel.
- Add `InfoCenter` to display balloon information in the AutoCAD InfoCenter.
- Add `RibbonListButton` in the `RibbonThemePanelUtils`.
### Example
- Add `CircleCreate` command to the example project.
- Add `MessageBox` and `ShowBalloon` buttons to the example ribbon panel.
- Update resource image to `Cube-Grey-Light.tiff` and `Cube-Grey-Dark.tiff`.
- Add `AutoCADBusyService` to update the button state in the example project.
- Add `AutoCADTaskService` to create multiple circles in the example project.
- Add `PaletteSetUtils` to show a palette set in the example project.
### Updates
- Fix `CheckURLValid` to support `http` and `https`.
- Fix `SetImage` to update `Image` property.
- Update `LockDocumentRelayCommand` to use `LockDocumentManager` to support document locking.
- Update `AutoCADTaskService` update `Application_Idle` to run single event handler.

## [0.1.0] / 2025-07-02
### Features
- `ExtensionApplication` and `RibbonControl` extension for AutoCAD ribbon UI.
Expand All @@ -13,4 +33,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add `Busy`, `Runtime`, `Tasks`, and `Windows` utilities.

[vNext]: ../../compare/1.0.0...HEAD
[0.2.0]: ../../compare/0.1.0...0.2.0
[0.1.0]: ../../compare/0.1.0
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>0.1.0</Version>
<Version>0.2.0-rc.2</Version>
</PropertyGroup>
</Project>
131 changes: 131 additions & 0 deletions ricaun.AutoCAD.UI.Example/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Windows;
using Autodesk.Windows;
using ricaun.AutoCAD.UI.Busy;
using ricaun.AutoCAD.UI.Tasks;
using ricaun.AutoCAD.UI.Windows;
using System;
using System.Diagnostics;
using System.Threading.Tasks;

[assembly: ExtensionApplication(typeof(ricaun.AutoCAD.UI.Example.App))]

namespace ricaun.AutoCAD.UI.Example
{
public class App : ExtensionApplication
{
private const string PanelName = "Example";
private const string TabName = "ricaun";

public override void OnStartup(RibbonControl ribbonControl)
{
var ribbonPanel = ribbonControl.CreateOrSelectPanel(PanelName, TabName);

ribbonPanel.RowLargeStackedItems(
ribbonPanel.CreateButton("Theme")
.SetShowText(false)
.SetCommand(Commands.ThemeChange)
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Grey-Light.tiff"),
ribbonPanel.CreateButton("Theme")
.SetShowText(false)
.SetCommand(Commands.ThemeChange)
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Red-Light.tiff"),
ribbonPanel.CreateButton("Theme")
.SetCommand(Commands.ThemeChange)
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Green-Light.ico"),
ribbonPanel.CreateButton("Theme")
.SetCommand(Commands.ThemeChange)
.SetLargeImage("https://github.com/ricaun-io/Autodesk.Icon.Example/releases/download/2.0.0/Box-Blue-32-Light.png")
);

ribbonPanel.AddSeparator();

ribbonPanel.CreateButton("Circle\rCreate")
.SetCommand(Commands.CircleCreate)
.SetDescription("Create a circle with a random radius in the model space.")
.SetToolTip("This button use the command 'CircleCreate'.")
.SetLargeImage("Resources/Cube-Grey-Light.tiff");

ribbonPanel.CreateButton("Show\rMessage")
.SetCommand((item) => { Windows.MessageBox.ShowMessage(item.Text, "This is a custom message."); })
.SetLargeImage("Resources/Cube-Grey-Light.tiff");

ribbonPanel.CreateButton("Show\rBalloon")
.SetCommand((item) => { Windows.InfoCenter.ShowBalloon(item.Text, "This is a custom message."); })
.SetLargeImage("Resources/Cube-Grey-Light.tiff");

ribbonButtonBusy = ribbonPanel.CreateButton("None")
.SetLargeImage("Resources/Cube-Grey-Light.tiff");

ribbonPanel.CreateButton("Task")
.SetCommand((item) =>
{
if (autoCADTask is null) return;
item.IsEnabled = false;
Task.Run(async () =>
{
try
{
for (int i = 0; i < 10; i++)
{
await autoCADTask.Run(Commands.CircleCreate);
await Task.Delay(100);
}
}
finally
{
await autoCADTask.Run(() =>
{
item.IsEnabled = true;
});
}
});
})
.SetLargeImage("Resources/Cube-Grey-Light.tiff");

ribbonPanel.CreateButton("Show\rPalette")
.SetCommand(() => { paletteSet?.ToggleVisible(); })
.SetLargeImage("Resources/Cube-Grey-Light.tiff");

ribbonControl.ActiveTab = ribbonPanel.Tab;
}
public override void OnShutdown(RibbonControl ribbonControl)
{
ribbonControl.RemovePanel(PanelName, TabName);
}

private RibbonButton ribbonButtonBusy;
private PaletteSet paletteSet;
private AutoCADBusyService busyService;
private AutoCADTaskService taskService;
public IAutoCADTask autoCADTask => taskService;
public override void Initialize()
{
base.Initialize();
busyService = new AutoCADBusyService();
busyService.Initialize();
busyService.PropertyChanged += (sender, e) =>
{
ribbonButtonBusy?.SetText(busyService.IsAutoCADBusy ? "Busy" : "Idle");
var color = busyService.IsAutoCADBusy ? "Red" : "Green";
ribbonButtonBusy?.SetLargeImage($"Resources/Cube-{color}-Light.tiff");
};
taskService = new AutoCADTaskService();
taskService.Initialize();

var visual = new System.Windows.Controls.Grid()
{
Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray),
};
paletteSet = PaletteSetUtils.Create("Example Palette Set", new Guid("360B945E-1EFF-4212-9C00-3E841A9F1B28"), visual);
}

public override void Terminate()
{
base.Terminate();
busyService?.Dispose();
taskService?.Dispose();
}
}
}
44 changes: 44 additions & 0 deletions ricaun.AutoCAD.UI.Example/Commands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using System;

namespace ricaun.AutoCAD.UI.Example
{
public static class Commands
{
[CommandMethod("ThemeChange")]
public static void ThemeChange()
{
Application.SetSystemVariable("COLORTHEME", 1 ^ (short)Application.GetSystemVariable("COLORTHEME"));
}

[CommandMethod("CircleCreate")]
public static void CircleCreate()
{
Document document = Application.DocumentManager.MdiActiveDocument;

if (document is null) return;

var database = document.Database;

using (var transaction = database.TransactionManager.StartTransaction())
{
var blockTable = transaction.GetObject(database.BlockTableId, OpenMode.ForRead) as BlockTable;
var blockTableRecord = transaction.GetObject(blockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

var circle = new Circle()
{
Radius = new Random().NextDouble() * 100.0,
Center = new Point3d(0, 0, 0),
};

blockTableRecord.AppendEntity(circle);

transaction.AddNewlyCreatedDBObject(circle, true);
transaction.Commit();
}
}
}
}
Loading