From 3b56e7a95d7714268dc01c72e5f9e33150353d22 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Thu, 23 Jun 2022 23:28:17 -0300 Subject: [PATCH 01/15] Update Build net6.0 --- Build/Build.cs | 1 - Build/Build.csproj | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Build/Build.cs b/Build/Build.cs index ab40a25..a26ecc4 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -3,7 +3,6 @@ using ricaun.Nuke; using ricaun.Nuke.Components; -[CheckBuildProjectConfigurations] class Build : NukeBuild, IPublishRevit { string IHazRevitPackageBuilder.Application => "Revit.App"; diff --git a/Build/Build.csproj b/Build/Build.csproj index b55853a..a67ae4e 100644 --- a/Build/Build.csproj +++ b/Build/Build.csproj @@ -1,7 +1,7 @@  Exe - net5.0 + net6.0 CS0649;CS0169 . From b3a5a8e3d15429c4ae6ca79176e2cd329ce7982f Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Mon, 4 Mar 2024 12:25:12 -0300 Subject: [PATCH 02/15] Test in Revit 2024 --- CHANGELOG.md | 5 ++ README.md | 2 +- .../Revit/App.cs | 4 +- .../Revit/Commands/ClickHandler.cs | 52 +++++++++++++++ .../Revit/Commands/Command.cs | 62 ++++-------------- ...RevitAddin.TemporaryGraphicsExample.csproj | 9 ++- .../device_power_browser.bmp | Bin 0 -> 1078 bytes .../image16.bmp | Bin 0 -> 2166 bytes 8 files changed, 81 insertions(+), 53 deletions(-) create mode 100644 RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs create mode 100644 RevitAddin.TemporaryGraphicsExample/device_power_browser.bmp create mode 100644 RevitAddin.TemporaryGraphicsExample/image16.bmp diff --git a/CHANGELOG.md b/CHANGELOG.md index b443ee6..4f760c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,16 @@ 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). +## [1.0.2] / 2024-03-04 +- Update references +- Test in Revit 2024 + ## [1.0.1] / 2022-04-26 - Add Installation Files ## [1.0.0] / 2022-04-25 - First Release +[1.0.2]: ../../compare/1.0.1...1.0.2 [1.0.1]: ../../compare/1.0.0...1.0.1 [1.0.0]: ../../compare/1.0.0 \ No newline at end of file diff --git a/README.md b/README.md index 730ebb5..27a8d54 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ RevitAddin Example to work with [TemporaryGraphicsManager] a new feature of Revi [TemporaryGraphicsManager] enables the ability to show the image on the view, a click event on the image could be created. [![Revit 2022](https://img.shields.io/badge/Revit-2022+-blue.svg)](../..) -[![Visual Studio 2019](https://img.shields.io/badge/Visual%20Studio%202019-16.11.7+-blue)](../..) +[![Visual Studio 2022](https://img.shields.io/badge/Visual%20Studio%20-2022-blue)](../..) [![Nuke](https://img.shields.io/badge/Nuke-Build-blue)](https://nuke.build/) [![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![Publish](../../actions/workflows/Publish.yml/badge.svg)](../../actions) diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs index d27ef46..0cf5735 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs @@ -5,14 +5,14 @@ namespace RevitAddin.TemporaryGraphicsExample.Revit { - [Console] + [AppLoader] public class App : IExternalApplication { private static RibbonPanel ribbonPanel; public Result OnStartup(UIControlledApplication application) { ribbonPanel = application.CreatePanel("Graphics"); - ribbonPanel.AddPushButton("Temporary") + ribbonPanel.CreatePushButton("Temporary") .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); return Result.Succeeded; diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs new file mode 100644 index 0000000..288bccf --- /dev/null +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs @@ -0,0 +1,52 @@ +using Autodesk.Revit.DB.ExternalService; +using Autodesk.Revit.UI; +using System; +using System.Collections.Generic; + +namespace RevitAddin.TemporaryGraphicsExample.Revit.Commands +{ + class ClickHandler : ITemporaryGraphicsHandler + { + public void AddServer() + { + Guid guid = GetServerId(); + var services = (MultiServerService)ExternalServiceRegistry.GetService(GetServiceId()); + + if (services.IsRegisteredServerId(guid)) + services.RemoveServer(guid); + + services.AddServer(this); + services.SetActiveServers(new List { guid }); + } + + public string GetDescription() + { + return "Click Temporary Graphics Handler"; + } + + public string GetName() + { + return "Click Temporary Graphics Handler"; + } + + public Guid GetServerId() + { + return new Guid("7B469077-9F7C-4CCF-9746-BD0DE41D3610"); + } + + public ExternalServiceId GetServiceId() + { + return ExternalServices.BuiltInExternalServices.TemporaryGraphicsHandlerService; + } + + public string GetVendorId() + { + return "ricaun"; + } + + public void OnClick(TemporaryGraphicsCommandData data) + { + System.Windows.MessageBox.Show($"TemporaryGraphics {data.Index}"); + } + } +} diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs index f406aae..5e3cfda 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs @@ -1,10 +1,8 @@ using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; -using Autodesk.Revit.DB.ExternalService; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; using System; -using System.Collections.Generic; using System.IO; using System.Reflection; @@ -13,6 +11,7 @@ namespace RevitAddin.TemporaryGraphicsExample.Revit.Commands [Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { + private Random Random = new Random(); public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) { UIApplication uiapp = commandData.Application; @@ -27,7 +26,19 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme { temporaryGraphicsManager.Clear(); var point = selection.PickPoint(); - var imagePath = Path.Combine(Location, "image.bmp"); + + var imageName = "image.bmp"; + var random = Random.NextDouble(); + if (random > 0.3) + { + imageName = "image16.bmp"; + } + if (random > 0.8) + { + imageName = "device_power_browser.bmp"; + } + + var imagePath = Path.Combine(Location, imageName); var data = new InCanvasControlData(imagePath, point); var indexClick = temporaryGraphicsManager.AddControl(data, ElementId.InvalidElementId); } @@ -37,49 +48,4 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme public string Location => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } - - public class ClickHandler : ITemporaryGraphicsHandler - { - public void AddServer() - { - Guid guid = GetServerId(); - var services = (MultiServerService)ExternalServiceRegistry.GetService(GetServiceId()); - - if (services.IsRegisteredServerId(guid)) - services.RemoveServer(guid); - - services.AddServer(this); - services.SetActiveServers(new List { guid }); - } - - public string GetDescription() - { - return "Click Temporary Graphics Handler"; - } - - public string GetName() - { - return "Click Temporary Graphics Handler"; - } - - public Guid GetServerId() - { - return new Guid("7B469077-9F7C-4CCF-9746-BD0DE41D3610"); - } - - public ExternalServiceId GetServiceId() - { - return ExternalServices.BuiltInExternalServices.TemporaryGraphicsHandlerService; - } - - public string GetVendorId() - { - return "ricaun"; - } - - public void OnClick(TemporaryGraphicsCommandData data) - { - System.Windows.MessageBox.Show($"TemporaryGraphics {data.Index}"); - } - } } diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index c589fdd..1337ce0 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -2,11 +2,10 @@ - net46 Library AnyCPU true - 9 + Latest false None Debug; Release @@ -144,9 +143,15 @@ Always + + Always + Always + + Always + \ No newline at end of file diff --git a/RevitAddin.TemporaryGraphicsExample/device_power_browser.bmp b/RevitAddin.TemporaryGraphicsExample/device_power_browser.bmp new file mode 100644 index 0000000000000000000000000000000000000000..2727ce1f6dee8c5b3e68caad4a1c0c00f440c835 GIT binary patch literal 1078 zcmcJOOG_J36vrdD>qh(pu0rtxh`MN@^@$2aQyNNBd<7I#L`2(yk1Ewg1x2h7TO~fC z<|+6gj39yoNuwrO$0Rd4Cl8%8E^-%o&)5S>gB$U}fA0UBdw%EMdA+JD%GGJ3h+m&` z<^5BRu7JDSk^fAmLp{}4u*~X52R?gSO-8xuWhtQ0^W4_rFN^-6eZPPE>N3<;DD6!j zz~fkju=odp2LZ5I=b^*g2)H&eHsZ|IgR@RUO$BUvoN$>;Ksu$~Qz8bizHEj1>N3FE zyFKP+ru5i*)9nEDBJrRcwnZ@1lq<+kkD*V!TitCf0A~^;V+vHhD89D;oW4enLXSE0 z=TZdBCL?ghOMLTtgX~^gff(me#8XT>#n!o5K!$i;4+nk$&ZDQAh^Lr%iv7Yae=j9K zJo-?;2a{S| vva3{zMZ;powYrqXHLRifZ1cqEU}1k(oA=|}H~jx8(VjDU%;8!#<}tY&MSka& literal 0 HcmV?d00001 diff --git a/RevitAddin.TemporaryGraphicsExample/image16.bmp b/RevitAddin.TemporaryGraphicsExample/image16.bmp new file mode 100644 index 0000000000000000000000000000000000000000..67c845dfc9c73fc8fe771d8371afd83d64495e09 GIT binary patch literal 2166 zcmZ?rE#qJSgEAng0mKea%*en3WB~zG9>PH;8yFaXh@qhYLIFu26Nnoa4jecDl=u%u z4FCUwSU?PfAR!=;HVTGA2+TwW6HsC{6J2^H0|Oh9zv&>4WE+TyVgIN+N(hXG4;xZ= s0MjQD55yb|A2y^Ap*VbiwE{XoHa`Jf63C~fJTN*j0Fw7cnKTOl0D@u_DF6Tf literal 0 HcmV?d00001 From 127f295cadceeb67829e219b8e9e21b875d02014 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Mon, 4 Mar 2024 18:50:05 -0300 Subject: [PATCH 03/15] Update point --- .../Revit/App.cs | 3 ++ .../Revit/Commands/Command.cs | 41 +++++++++++------- .../Revit/Commands/CommandClear.cs | 24 ++++++++++ ...RevitAddin.TemporaryGraphicsExample.csproj | 3 ++ RevitAddin.TemporaryGraphicsExample/point.bmp | Bin 0 -> 1254 bytes 5 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandClear.cs create mode 100644 RevitAddin.TemporaryGraphicsExample/point.bmp diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs index 0cf5735..21694b1 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs @@ -15,6 +15,9 @@ public Result OnStartup(UIControlledApplication application) ribbonPanel.CreatePushButton("Temporary") .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); + ribbonPanel.CreatePushButton("Clear") + .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); + return Result.Succeeded; } diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs index 5e3cfda..133c964 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs @@ -15,37 +15,46 @@ public class Command : IExternalCommand public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) { UIApplication uiapp = commandData.Application; + UIDocument uidoc = uiapp.ActiveUIDocument; Document document = uidoc.Document; + View view = uidoc.ActiveView; Selection selection = uidoc.Selection; var clickHandle = new ClickHandler(); clickHandle.AddServer(); - using (var temporaryGraphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(document)) + try { - temporaryGraphicsManager.Clear(); - var point = selection.PickPoint(); - - var imageName = "image.bmp"; - var random = Random.NextDouble(); - if (random > 0.3) + using (var temporaryGraphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(document)) { - imageName = "image16.bmp"; - } - if (random > 0.8) - { - imageName = "device_power_browser.bmp"; - } + //temporaryGraphicsManager.Clear(); + var point = selection.PickPoint(); - var imagePath = Path.Combine(Location, imageName); - var data = new InCanvasControlData(imagePath, point); - var indexClick = temporaryGraphicsManager.AddControl(data, ElementId.InvalidElementId); + var imageName = "image.bmp"; + var random = Random.NextDouble(); + if (random > 0.3) + { + imageName = "image16.bmp"; + } + if (random > 0.8) + { + imageName = "device_power_browser.bmp"; + } + + imageName = "point.bmp"; + + var imagePath = Path.Combine(Location, imageName); + var data = new InCanvasControlData(imagePath, point); + var indexClick = temporaryGraphicsManager.AddControl(data, ElementId.InvalidElementId); + } } + catch { } return Result.Succeeded; } public string Location => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } + } diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandClear.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandClear.cs new file mode 100644 index 0000000..4a424fc --- /dev/null +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandClear.cs @@ -0,0 +1,24 @@ +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; + +namespace RevitAddin.TemporaryGraphicsExample.Revit.Commands +{ + [Transaction(TransactionMode.Manual)] + public class CommandClear : IExternalCommand + { + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) + { + UIApplication uiapp = commandData.Application; + + Document document = uiapp.ActiveUIDocument.Document; + using (var temporaryGraphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(document)) + { + temporaryGraphicsManager.Clear(); + } + + return Result.Succeeded; + } + } + +} diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index 1337ce0..7042f7a 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -152,6 +152,9 @@ Always + + PreserveNewest + \ No newline at end of file diff --git a/RevitAddin.TemporaryGraphicsExample/point.bmp b/RevitAddin.TemporaryGraphicsExample/point.bmp new file mode 100644 index 0000000000000000000000000000000000000000..0c35315f27ff1b26ea2d87f0e99be1fa461dfcee GIT binary patch literal 1254 wcmZ?rea6B724+A~1BgYSn2|vOEWQCM59UA#_4@y#Xfy;yLtr!nhC~Pe0Hyqty8r+H literal 0 HcmV?d00001 From 7f7d59639c686e7a0f353b1be0d49fd03718d666 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 5 Mar 2024 11:31:42 -0300 Subject: [PATCH 04/15] Update --- RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs | 4 ++-- .../RevitAddin.TemporaryGraphicsExample.csproj | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs index 133c964..6b46793 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs @@ -1,4 +1,4 @@ -using Autodesk.Revit.Attributes; +using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; @@ -55,6 +55,6 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme } public string Location => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - } + } } diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index 7042f7a..f761ff2 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -120,7 +120,6 @@ - From 33ad1860b74b8efba5409e9002fc1f495af5a8e6 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Tue, 5 Mar 2024 11:31:57 -0300 Subject: [PATCH 05/15] Update --- RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs index 6b46793..5d27a02 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs @@ -42,7 +42,7 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme imageName = "device_power_browser.bmp"; } - imageName = "point.bmp"; + //imageName = "point.bmp"; var imagePath = Path.Combine(Location, imageName); var data = new InCanvasControlData(imagePath, point); From ff516a8f20b7400e50e96a89ab6748e12d12b65e Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 10:40:08 -0300 Subject: [PATCH 06/15] Update to Revit 2025 --- CHANGELOG.md | 3 + README.md | 2 +- ...RevitAddin.TemporaryGraphicsExample.csproj | 56 +++++-------------- 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f760c0..b75056b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ 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). +## [1.0.3] / 2025-01-04 +- Update to Revit 2025 + ## [1.0.2] / 2024-03-04 - Update references - Test in Revit 2024 diff --git a/README.md b/README.md index 27a8d54..6ae9568 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ RevitAddin Example to work with [TemporaryGraphicsManager] a new feature of Revi ## License -This project is [licensed](LICENSE) under the [MIT Licence](https://en.wikipedia.org/wiki/MIT_License). +This project is [licensed](LICENSE) under the [MIT License](https://en.wikipedia.org/wiki/MIT_License). --- diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index f761ff2..5e99465 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -12,57 +12,31 @@ + + net48;net8.0-windows + true + None + - - - 2017 - net46 - - - - - 2018 - net46 - - - - - 2019 - net47 - - - - - 2020 - net47 - - - - - 2021 - net48 - - - + 2022 - net48 - - - - - 2023 - net48 - 2022 - net48 + 2025 + + + true + true + false + + true @@ -89,7 +63,7 @@ RevitAddin.TemporaryGraphicsExample - 1.0.1 + 1.0.3 {A3399E68-62E1-4C44-8313-FFBBD8A9272F} From d6f94304758470bc8d2997dae322efa9f261e4a4 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 10:40:25 -0300 Subject: [PATCH 07/15] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b75056b..be94f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [1.0.0] / 2022-04-25 - First Release +[1.0.3]: ../../compare/1.0.2...1.0.3 [1.0.2]: ../../compare/1.0.1...1.0.2 [1.0.1]: ../../compare/1.0.0...1.0.1 [1.0.0]: ../../compare/1.0.0 \ No newline at end of file From e6d3563e0142b59aa5817f92450ad4966f56d6e6 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 10:59:30 -0300 Subject: [PATCH 08/15] Update `ClickHandler` --- CHANGELOG.md | 5 +-- .../Revit/App.cs | 7 ++++ .../Revit/Commands/ClickHandler.cs | 34 ++++++++++++++++--- .../Revit/Commands/Command.cs | 3 -- ...RevitAddin.TemporaryGraphicsExample.csproj | 6 ++-- 5 files changed, 42 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be94f90..07f0171 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ 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). -## [1.0.3] / 2025-01-04 +## [1.1.0] / 2025-01-04 - Update to Revit 2025 +- Update `ClickHandler` ## [1.0.2] / 2024-03-04 - Update references @@ -17,7 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [1.0.0] / 2022-04-25 - First Release -[1.0.3]: ../../compare/1.0.2...1.0.3 +[1.1.0]: ../../compare/1.0.1...1.1.0 [1.0.2]: ../../compare/1.0.1...1.0.2 [1.0.1]: ../../compare/1.0.0...1.0.1 [1.0.0]: ../../compare/1.0.0 \ No newline at end of file diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs index 21694b1..cec7785 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs @@ -1,5 +1,6 @@ using Autodesk.Revit.DB; using Autodesk.Revit.UI; +using RevitAddin.TemporaryGraphicsExample.Revit.Commands; using ricaun.Revit.UI; using System; @@ -9,6 +10,7 @@ namespace RevitAddin.TemporaryGraphicsExample.Revit public class App : IExternalApplication { private static RibbonPanel ribbonPanel; + public ClickHandler clickHandle = new ClickHandler(); public Result OnStartup(UIControlledApplication application) { ribbonPanel = application.CreatePanel("Graphics"); @@ -18,12 +20,17 @@ public Result OnStartup(UIControlledApplication application) ribbonPanel.CreatePushButton("Clear") .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); + clickHandle.AddServer(); + return Result.Succeeded; } public Result OnShutdown(UIControlledApplication application) { ribbonPanel?.Remove(); + + clickHandle.RemoveServer(); + return Result.Succeeded; } } diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs index 288bccf..112cad4 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs @@ -5,18 +5,42 @@ namespace RevitAddin.TemporaryGraphicsExample.Revit.Commands { - class ClickHandler : ITemporaryGraphicsHandler + public class ClickHandler : ITemporaryGraphicsHandler { + private Guid serverId; + public ClickHandler() : this(Guid.NewGuid()) + { + } + public ClickHandler(Guid serverId) { + this.serverId = serverId; + } + public void AddServer() { Guid guid = GetServerId(); var services = (MultiServerService)ExternalServiceRegistry.GetService(GetServiceId()); if (services.IsRegisteredServerId(guid)) - services.RemoveServer(guid); + return; services.AddServer(this); - services.SetActiveServers(new List { guid }); + var activeServerIds = services.GetActiveServerIds(); + activeServerIds.Add(guid); + services.SetActiveServers(activeServerIds); + } + + public void RemoveServer() + { + Guid guid = GetServerId(); + var services = (MultiServerService)ExternalServiceRegistry.GetService(GetServiceId()); + + if (services.IsRegisteredServerId(guid)) + { + var activeServerIds = services.GetActiveServerIds(); + activeServerIds.Remove(guid); + services.SetActiveServers(activeServerIds); + services.RemoveServer(guid); + } } public string GetDescription() @@ -31,7 +55,7 @@ public string GetName() public Guid GetServerId() { - return new Guid("7B469077-9F7C-4CCF-9746-BD0DE41D3610"); + return serverId; } public ExternalServiceId GetServiceId() @@ -46,7 +70,7 @@ public string GetVendorId() public void OnClick(TemporaryGraphicsCommandData data) { - System.Windows.MessageBox.Show($"TemporaryGraphics {data.Index}"); + System.Windows.MessageBox.Show($"TemporaryGraphics {data.Index} {data.Document.Application.ActiveAddInId?.GetAddInName()}"); } } } diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs index 5d27a02..1afa46b 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs @@ -21,9 +21,6 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme View view = uidoc.ActiveView; Selection selection = uidoc.Selection; - var clickHandle = new ClickHandler(); - clickHandle.AddServer(); - try { using (var temporaryGraphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(document)) diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index 5e99465..de72713 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -63,7 +63,7 @@ RevitAddin.TemporaryGraphicsExample - 1.0.3 + 1.1.0 {A3399E68-62E1-4C44-8313-FFBBD8A9272F} @@ -76,8 +76,8 @@ - Company - Authors + ricaun + Luiz Henrique Cassettari Revit Add-In Description for $(PackageId). $([System.DateTime]::Now.ToString('yyyy')) From 259b48565bfb561fbe667acae4d514297b91aef3 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 11:00:42 -0300 Subject: [PATCH 09/15] Update Build --- .github/workflows/{Publish.yml => Build.yml} | 6 ++--- .github/workflows/Develop.yml | 25 -------------------- Build/Build.csproj | 7 +++--- README.md | 3 +-- 4 files changed, 8 insertions(+), 33 deletions(-) rename .github/workflows/{Publish.yml => Build.yml} (93%) delete mode 100644 .github/workflows/Develop.yml diff --git a/.github/workflows/Publish.yml b/.github/workflows/Build.yml similarity index 93% rename from .github/workflows/Publish.yml rename to .github/workflows/Build.yml index 9118c29..a32efeb 100644 --- a/.github/workflows/Publish.yml +++ b/.github/workflows/Build.yml @@ -1,8 +1,8 @@ # ------------------------------------------------------------------------------ -# Publish.yml +# Build.yml # ------------------------------------------------------------------------------ -name: Publish +name: Build on: push: @@ -12,7 +12,7 @@ on: jobs: Publish: - name: Publish + name: Build runs-on: windows-latest steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/Develop.yml b/.github/workflows/Develop.yml deleted file mode 100644 index e6b11f6..0000000 --- a/.github/workflows/Develop.yml +++ /dev/null @@ -1,25 +0,0 @@ -# ------------------------------------------------------------------------------ -# Develop.yml -# ------------------------------------------------------------------------------ - -name: Develop - -on: - push: - branches-ignore: - - master - pull_request: - branches-ignore: - - master - workflow_dispatch: - -jobs: - Develop: - name: Develop - runs-on: windows-latest - steps: - - uses: actions/checkout@v1 - - name: Run './build/build.cmd' - run: ./build/build.cmd --root ./build - env: - GitHubToken: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/Build/Build.csproj b/Build/Build.csproj index a67ae4e..40b00ac 100644 --- a/Build/Build.csproj +++ b/Build/Build.csproj @@ -1,7 +1,7 @@  Exe - net6.0 + net8.0 CS0649;CS0169 . @@ -15,7 +15,8 @@ - - + + + diff --git a/README.md b/README.md index 6ae9568..a1817ce 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,7 @@ RevitAddin Example to work with [TemporaryGraphicsManager] a new feature of Revi [![Visual Studio 2022](https://img.shields.io/badge/Visual%20Studio%20-2022-blue)](../..) [![Nuke](https://img.shields.io/badge/Nuke-Build-blue)](https://nuke.build/) [![License MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) -[![Publish](../../actions/workflows/Publish.yml/badge.svg)](../../actions) -[![Develop](../../actions/workflows/Develop.yml/badge.svg)](../../actions) +[![Build](../../actions/workflows/Build.yml/badge.svg)](../../actions) ## Release From b49bbc4af5603e97fa164345880bce02fe793e6b Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 11:13:46 -0300 Subject: [PATCH 10/15] Add circle multiple bmp --- .../Revit/Commands/Command.cs | 25 ++++++------------ ...RevitAddin.TemporaryGraphicsExample.csproj | 2 +- .../circle.bmp | Bin 0 -> 110646 bytes 3 files changed, 9 insertions(+), 18 deletions(-) create mode 100644 RevitAddin.TemporaryGraphicsExample/circle.bmp diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs index 1afa46b..abc0884 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/Command.cs @@ -25,25 +25,14 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme { using (var temporaryGraphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(document)) { - //temporaryGraphicsManager.Clear(); - var point = selection.PickPoint(); - - var imageName = "image.bmp"; - var random = Random.NextDouble(); - if (random > 0.3) - { - imageName = "image16.bmp"; - } - if (random > 0.8) + while (true) { - imageName = "device_power_browser.bmp"; - } - - //imageName = "point.bmp"; + var point = selection.PickPoint(); - var imagePath = Path.Combine(Location, imageName); - var data = new InCanvasControlData(imagePath, point); - var indexClick = temporaryGraphicsManager.AddControl(data, ElementId.InvalidElementId); + var imagePath = Images[Index++ % Images.Length]; + var data = new InCanvasControlData(imagePath, point); + var indexClick = temporaryGraphicsManager.AddControl(data, ElementId.InvalidElementId); + } } } catch { } @@ -51,7 +40,9 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme return Result.Succeeded; } + public static int Index = 0; public string Location => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + public string[] Images => Directory.GetFiles(Location, "*.bmp"); } } diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index de72713..dce1f49 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -126,7 +126,7 @@ Always - PreserveNewest + Always diff --git a/RevitAddin.TemporaryGraphicsExample/circle.bmp b/RevitAddin.TemporaryGraphicsExample/circle.bmp new file mode 100644 index 0000000000000000000000000000000000000000..f03c5594c2b49279e379a7d55bb81f9736fd41e7 GIT binary patch literal 110646 zcmeI2&5dM55QKZZ-~cxyuwV_~j!oEuYY`b{rm5$eE%%pfBygd<@KF>l7I62_a9#WeLowo*SBx{A^{R00TLhq5+DH* zAOR8}0TLhq5+DKV1b+PfujViQ@5gNfnxj&9@iw0B=PmSo(lPgVT@E-Y44q|NqV_aY zr@t$&d%}MDES&4sgg+z z8e~~g7U@R2C$-LwY}qe6+OilY*=M9|c6>Wd8B~&{XT;(KGSVF6sX_1dN=g%3V42Mp z2`qd4GSxjn$)>Fx=LYB=*o~|hy8_I`e)~1NjUgP!f zF0pZ}VfUmb#(cQB3kn8j@nn|GS%TPQbAjUnTLh=D3EZVB&3~Y|vrB35E-%qMF*L|N0qt6U5*jLK8TQdp;X^=s*ARftD_R5HIf#I^ zuQLx-*LC-U&{3)o&<<7wpy#k|O-D{7pndE~MfqLb_e6TstbHucK=Vo6lt!FOK)cx- zjFOAG-MQ$f{2`z{ElEP#8QqI6oK8S{+Ln#%E#2sJbkzS4(9UMV&~QL^A%7nPw6hKI z$X%WNL14(R$M?}>o+w<;dl!%*K7I?nPC0E@GcC_ey|Wl84#2xynf z6Ouj&mHnaPL=OQlI-QEbr%+Rtr0tb}_PQ`6iDOXHD>}~g5CFRq!6_JpsC^H{BfAN82=*QVV0|_! z!2?j_9(tSY^qMyR`tI%;+Apil;2}$q3bt1iu00bbN7I+GG zWqBJt&MO2U1`v|O5-t+vodh5TiNL@kxOgW$P7N`DkR+CHktFXV05M1e=JOHUlI5NB zIJFRfFns1D_8G1a2Y=l!)H!npWzA_-b?_(5X;QxK3ut(9%qLz zeC8zh8O{?R2|y%*v3YO8VbUW3h{QW8!4Ghl^hf|A5sb}y6AqIe2|y&?Q3-y4!=y(7 z5Q$)H-kWfk^hf|A@s5iA04HThdL$qOAQ(D1&kh_TIudvYKrome2BV4q^HYV3hk*d| z13y_Iiu?@#^fFxtO0doV|AG&yQ5_3WsxL2{hz~zXD~c zUUHx{P0JZ z*PO)W>dX&cK{2p5>_d2DDS4>2xbpOjIm>=nKIcJySLwIC4DnC*Oin|1O`A}f-!0_n&NUzIjI~yOuBg?V*(GhY6 z@bYoi=ZCK#H<4Qq9{v7dewd%ypK&^j373BWNGn^3ZTgx4w}7(IaaI8)DFNMGH8Z z=T+jhcRfjHyQ?)^Wx>(IYVX=I(0NPCIGXAu;{WCoKZW~Y5l0{TG)wreQVYpjdFiT9WBqd9cN9a-5Fx~z#>|q z?3@MJtJPr&*>QsKXSh7IW^f9#%-skJVxMaCyyC%G+&E=$kRWi` zoM-Xu%E5^Yl6N2}i2CU8JmCz^<-jjfBLpGOemN|wADqq<|D(kO@h&rWO{3t9vU#*| z+r`JIuJLqnm)Nk|T{u)gjOSuoSGJ3de5ivPWyeUabaP9u*x<6i(T;;!Cjf3SbW771 zgoAwCA~nWM_P6-Bv1tOu7Hf<*P2k#S;@;K?CdS=dEH43SuY(r4C*Ul$$zZz#91GqV z(U71dj||$nKvJ5C5#vnBNE2INnUNN04yG)#CMJzeo*J=ul8o&5*8H-mCyQ~CeH+VW zN4DvdWmQ?E8|@z0Iy?E3ko*vBv9h)yfdBRdEFX;c~N;PTbq}9W)o;m)NEm_ JPXg`<`~#!u$Qu9v literal 0 HcmV?d00001 From 83aacff0ef3c44a12aecd9c4d16108455ae1179b Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 11:15:21 -0300 Subject: [PATCH 11/15] Update `ClickHandler` --- RevitAddin.TemporaryGraphicsExample/Revit/App.cs | 1 - .../Revit/{Commands => }/ClickHandler.cs | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename RevitAddin.TemporaryGraphicsExample/Revit/{Commands => }/ClickHandler.cs (95%) diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs index cec7785..f9c9491 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs @@ -1,6 +1,5 @@ using Autodesk.Revit.DB; using Autodesk.Revit.UI; -using RevitAddin.TemporaryGraphicsExample.Revit.Commands; using ricaun.Revit.UI; using System; diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs b/RevitAddin.TemporaryGraphicsExample/Revit/ClickHandler.cs similarity index 95% rename from RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs rename to RevitAddin.TemporaryGraphicsExample/Revit/ClickHandler.cs index 112cad4..e877312 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/ClickHandler.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/ClickHandler.cs @@ -3,7 +3,7 @@ using System; using System.Collections.Generic; -namespace RevitAddin.TemporaryGraphicsExample.Revit.Commands +namespace RevitAddin.TemporaryGraphicsExample.Revit { public class ClickHandler : ITemporaryGraphicsHandler { @@ -11,7 +11,8 @@ public class ClickHandler : ITemporaryGraphicsHandler public ClickHandler() : this(Guid.NewGuid()) { } - public ClickHandler(Guid serverId) { + public ClickHandler(Guid serverId) + { this.serverId = serverId; } From a9347439292c102add0e5bdd13b506b40ffc3f40 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 12:32:54 -0300 Subject: [PATCH 12/15] Add frames `Bad Apple` --- README.md | 2 + .../Revit/App.cs | 4 ++ .../Revit/Commands/CommandFrames.cs | 58 +++++++++++++++++++ .../Revit/ImageConverter.cs | 57 ++++++++++++++++++ .../Revit/RevitRibbonController.cs | 15 +++++ ...RevitAddin.TemporaryGraphicsExample.csproj | 3 + 6 files changed, 139 insertions(+) create mode 100644 RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandFrames.cs create mode 100644 RevitAddin.TemporaryGraphicsExample/Revit/ImageConverter.cs create mode 100644 RevitAddin.TemporaryGraphicsExample/Revit/RevitRibbonController.cs diff --git a/README.md b/README.md index a1817ce..453ea4b 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ RevitAddin Example to work with [TemporaryGraphicsManager] a new feature of Revi [TemporaryGraphicsManager] enables the ability to show the image on the view, a click event on the image could be created. +* [Revit_API_Revit_API_Developers_Guide_Basic_Interaction_with_Revit_Elements_Views_Temporary_Graphics](https://help.autodesk.com/view/RVT/2024/ENU/?guid=Revit_API_Revit_API_Developers_Guide_Basic_Interaction_with_Revit_Elements_Views_Temporary_Graphics_html) + [![Revit 2022](https://img.shields.io/badge/Revit-2022+-blue.svg)](../..) [![Visual Studio 2022](https://img.shields.io/badge/Visual%20Studio%20-2022-blue)](../..) [![Nuke](https://img.shields.io/badge/Nuke-Build-blue)](https://nuke.build/) diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs index f9c9491..a00a204 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs @@ -13,6 +13,10 @@ public class App : IExternalApplication public Result OnStartup(UIControlledApplication application) { ribbonPanel = application.CreatePanel("Graphics"); + + ribbonPanel.CreatePushButton("Frames") + .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); + ribbonPanel.CreatePushButton("Temporary") .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandFrames.cs b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandFrames.cs new file mode 100644 index 0000000..9b72131 --- /dev/null +++ b/RevitAddin.TemporaryGraphicsExample/Revit/Commands/CommandFrames.cs @@ -0,0 +1,58 @@ +using Autodesk.Revit.Attributes; +using Autodesk.Revit.DB; +using Autodesk.Revit.UI; +using System; +using System.IO; +using System.Reflection; + +namespace RevitAddin.TemporaryGraphicsExample.Revit.Commands +{ + [Transaction(TransactionMode.Manual)] + public class CommandFrames : IExternalCommand + { + public string Location => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet) + { + UIApplication uiapp = commandData.Application; + + var framesDirectory = "D:\\Downloads\\Download\\Bad Apple\\frames-bmp"; // 3 GB of files... + var frames = Directory.GetFiles(framesDirectory, "*.bmp"); + + int i = 0; + int indexClick = -1; + Document document = uiapp.ActiveUIDocument.Document; + using (var temporaryGraphicsManager = TemporaryGraphicsManager.GetTemporaryGraphicsManager(document)) + { + temporaryGraphicsManager.Clear(); + foreach (var frame in frames) + { + i++; + if (i % 10 == 0) + { + using var data = new InCanvasControlData(frame); + if (indexClick == -1) + { + indexClick = temporaryGraphicsManager.AddControl(data, ElementId.InvalidElementId); + } + else + { + temporaryGraphicsManager.UpdateControl(indexClick, data); + } + uiapp.ActiveUIDocument.RefreshActiveView(); + RevitRibbonController.ApplicationIdle(); + } + if (i % 150 == 0) + { + if (Console.CapsLock) + { + break; + } + } + } + } + + + return Result.Succeeded; + } + } +} diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/ImageConverter.cs b/RevitAddin.TemporaryGraphicsExample/Revit/ImageConverter.cs new file mode 100644 index 0000000..5e3ef4a --- /dev/null +++ b/RevitAddin.TemporaryGraphicsExample/Revit/ImageConverter.cs @@ -0,0 +1,57 @@ +using System; +using System.Drawing; +using System.Drawing.Imaging; + +namespace RevitAddin.TemporaryGraphicsExample.Revit +{ + public class ImageConverter + { + public static void ConvertPngToBmp(string inputPngPath, string outputBmpPath) + { + try + { + // Load the PNG image from the input path + using (Image image = Image.FromFile(inputPngPath)) + { + // Save the image as a BMP to the output path + image.Save(outputBmpPath, ImageFormat.Bmp); + } + } + catch (Exception ex) + { + Console.WriteLine("Error during conversion: " + ex.Message); + } + } + + public static void ConvertPngToBmpWithBackground(string inputPngPath, string outputBmpPath, Color backgroundColor) + { + try + { + // Load the PNG image from the input path + using (Image originalImage = Image.FromFile(inputPngPath)) + { + // Create a new bitmap with the same dimensions as the original image + using (Bitmap newImage = new Bitmap(originalImage.Width, originalImage.Height)) + { + // Create a Graphics object to draw on the new bitmap + using (Graphics graphics = Graphics.FromImage(newImage)) + { + // Fill the background with the specified background color + graphics.Clear(backgroundColor); + + // Draw the original image on top of the background + graphics.DrawImage(originalImage, 0, 0); + } + + // Save the new image as a BMP file + newImage.Save(outputBmpPath, ImageFormat.Bmp); + } + } + } + catch (Exception ex) + { + Console.WriteLine("Error during conversion: " + ex.Message); + } + } + } +} diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/RevitRibbonController.cs b/RevitAddin.TemporaryGraphicsExample/Revit/RevitRibbonController.cs new file mode 100644 index 0000000..82f1fba --- /dev/null +++ b/RevitAddin.TemporaryGraphicsExample/Revit/RevitRibbonController.cs @@ -0,0 +1,15 @@ +namespace RevitAddin.TemporaryGraphicsExample.Revit +{ + public class RevitRibbonController + { + /// + /// RibbonControl + /// + public static UIFramework.RevitRibbonControl RibbonControl => UIFramework.RevitRibbonControl.RibbonControl; + /// + /// Enable + /// + public static void ApplicationIdle() => UIFramework.RevitRibbonControl.RibbonControl.Dispatcher.Invoke(NoneMethod, System.Windows.Threading.DispatcherPriority.ApplicationIdle); + private static void NoneMethod() { } + } +} diff --git a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj index dce1f49..0f72f6d 100644 --- a/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj +++ b/RevitAddin.TemporaryGraphicsExample/RevitAddin.TemporaryGraphicsExample.csproj @@ -111,6 +111,9 @@ + + + From a7bc2b35233dcbc4e1ce16b59de96de764ea5c44 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 14:10:00 -0300 Subject: [PATCH 13/15] Remove Frames Button --- RevitAddin.TemporaryGraphicsExample/Revit/App.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs index a00a204..1cb3bee 100644 --- a/RevitAddin.TemporaryGraphicsExample/Revit/App.cs +++ b/RevitAddin.TemporaryGraphicsExample/Revit/App.cs @@ -14,8 +14,8 @@ public Result OnStartup(UIControlledApplication application) { ribbonPanel = application.CreatePanel("Graphics"); - ribbonPanel.CreatePushButton("Frames") - .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); + //ribbonPanel.CreatePushButton("Frames") + // .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); ribbonPanel.CreatePushButton("Temporary") .SetLargeImage("/UIFrameworkRes;component/ribbon/images/revit.ico"); From 8a4cdb0fe347eee8fe60006ac82cbd43c5f8f361 Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 14:11:24 -0300 Subject: [PATCH 14/15] build --- Build/.nuke/build.schema.json | 319 ++++++++++++++++++++++++---------- 1 file changed, 227 insertions(+), 92 deletions(-) diff --git a/Build/.nuke/build.schema.json b/Build/.nuke/build.schema.json index 8f8f53f..e3e90fe 100644 --- a/Build/.nuke/build.schema.json +++ b/Build/.nuke/build.schema.json @@ -1,60 +1,170 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Build Schema", - "$ref": "#/definitions/build", "definitions": { - "build": { + "Host": { + "type": "string", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "IssConfiguration": { "type": "object", + "description": "IssConfiguration", "properties": { - "Continue": { - "type": "boolean", - "description": "Indicates to continue a previously failed build attempt" + "Title": { + "type": [ + "null", + "string" + ], + "description": "Title (default null)" }, - "Folder": { - "type": "string" + "Image": { + "type": [ + "null", + "string" + ], + "description": "Image (default IMAGE)" }, - "GitHubToken": { - "type": "string", - "default": "Secrets must be entered via 'nuke :secret [profile]'" + "ImageSmall": { + "type": [ + "null", + "string" + ], + "description": "Small Image (default IMAGESMALL)" }, - "Help": { - "type": "boolean", - "description": "Shows the help text for this build assembly" + "Icon": { + "type": [ + "null", + "string" + ], + "description": "Icon (default ICON)" }, - "Host": { - "type": "string", - "description": "Host for execution. Default is 'automatic'", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" + "Licence": { + "type": [ + "null", + "string" + ], + "description": "Licence (default LICENSE)" + }, + "Language": { + "description": "Language (default IssLanguage)", + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/definitions/IssLanguage" + } ] }, - "InstallationFiles": { - "type": "string" + "IssLanguageLicences": { + "type": [ + "array", + "null" + ], + "description": "IssLanguages", + "items": { + "$ref": "#/definitions/IssLanguageLicence" + } + } + } + }, + "IssLanguage": { + "type": "object", + "description": "IssLanguage", + "properties": { + "Name": { + "type": [ + "null", + "string" + ], + "description": "Name (default \"en\")" }, - "IssConfiguration": { - "type": "string" + "MessagesFile": { + "type": [ + "null", + "string" + ], + "description": "MessagesFile (default \"compiler:Default.isl\")" + } + } + }, + "IssLanguageLicence": { + "type": "object", + "description": "IssLanguageLicence", + "properties": { + "Name": { + "type": [ + "null", + "string" + ], + "description": "Name (default \"en\")" }, - "MainName": { - "type": "string" + "MessagesFile": { + "type": [ + "null", + "string" + ], + "description": "MessagesFile (default \"compiler:Default.isl\")" }, - "Name": { - "type": "string" + "Licence": { + "type": [ + "null", + "string" + ], + "description": "Licence (default LICENSE)" + } + } + }, + "ExecutableTarget": { + "type": "string", + "enum": [ + "Build", + "Clean", + "Compile", + "GitRelease", + "PackageBuilder", + "Release", + "Sign" + ] + }, + "Verbosity": { + "type": "string", + "description": "", + "enum": [ + "Verbose", + "Normal", + "Minimal", + "Quiet" + ] + }, + "NukeBuild": { + "properties": { + "Continue": { + "type": "boolean", + "description": "Indicates to continue a previously failed build attempt" }, - "NewVersions": { - "type": "boolean" + "Help": { + "type": "boolean", + "description": "Shows the help text for this build assembly" + }, + "Host": { + "description": "Host for execution. Default is 'automatic'", + "$ref": "#/definitions/Host" }, "NoLogo": { "type": "boolean", @@ -75,83 +185,108 @@ "type": "string" } }, + "Root": { + "type": "string", + "description": "Root directory during build execution" + }, + "Skip": { + "type": "array", + "description": "List of targets to be skipped. Empty list skips all dependencies", + "items": { + "$ref": "#/definitions/ExecutableTarget" + } + }, + "Target": { + "type": "array", + "description": "List of targets to be invoked. Default is '{default_target}'", + "items": { + "$ref": "#/definitions/ExecutableTarget" + } + }, + "Verbosity": { + "description": "Logging verbosity during build execution. Default is 'Normal'", + "$ref": "#/definitions/Verbosity" + } + } + } + }, + "allOf": [ + { + "properties": { + "ApplicationType": { + "type": "string" + }, + "EnableForkedRepository": { + "type": "boolean" + }, + "Folder": { + "type": "string" + }, + "GitHubToken": { + "type": "string", + "default": "Secrets must be entered via 'nuke :secrets [profile]'" + }, + "InstallationFiles": { + "type": "string" + }, + "IssConfiguration": { + "$ref": "#/definitions/IssConfiguration" + }, + "MainName": { + "type": "string" + }, + "MiddleVersions": { + "type": "boolean" + }, + "Name": { + "type": "string" + }, + "NewVersions": { + "type": "boolean" + }, "ProjectNameFolder": { "type": "boolean" }, + "ProjectRemoveTargetFrameworkFolder": { + "type": "boolean" + }, "ProjectVersionFolder": { "type": "boolean" }, "ReleaseBundle": { "type": "boolean" }, - "ReleasePackageBuilder": { + "ReleaseFolder": { + "type": "string" + }, + "ReleaseNameVersion": { "type": "boolean" }, - "Root": { - "type": "string", - "description": "Root directory during build execution" + "ReleasePackageBuilder": { + "type": "boolean" }, "SignFile": { "type": "string", - "default": "Secrets must be entered via 'nuke :secret [profile]'" + "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, "SignPassword": { "type": "string", - "default": "Secrets must be entered via 'nuke :secret [profile]'" - }, - "Skip": { - "type": "array", - "description": "List of targets to be skipped. Empty list skips all dependencies", - "items": { - "type": "string", - "enum": [ - "Build", - "Clean", - "Compile", - "GitRelease", - "PackageBuilder", - "Release", - "Sign" - ] - } + "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, "Solution": { "type": "string", "description": "Path to a solution file that is automatically loaded" }, - "Target": { - "type": "array", - "description": "List of targets to be invoked. Default is '{default_target}'", - "items": { - "type": "string", - "enum": [ - "Build", - "Clean", - "Compile", - "GitRelease", - "PackageBuilder", - "Release", - "Sign" - ] - } - }, "VendorDescription": { "type": "string" }, "VendorId": { "type": "string" - }, - "Verbosity": { - "type": "string", - "description": "Logging verbosity during build execution. Default is 'Normal'", - "enum": [ - "Minimal", - "Normal", - "Quiet", - "Verbose" - ] } } + }, + { + "$ref": "#/definitions/NukeBuild" } - } -} \ No newline at end of file + ] +} From 170f281776c0c1be47a398ecd5ce06fcbbf0be5f Mon Sep 17 00:00:00 2001 From: Luiz Henrique Cassettari Date: Sat, 4 Jan 2025 14:13:27 -0300 Subject: [PATCH 15/15] Update build --- .github/workflows/Build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index a32efeb..bdf3eb4 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -6,8 +6,10 @@ name: Build on: push: - branches: + pull_request: + branches-ignore: - master + - main workflow_dispatch: jobs: