diff --git a/Build/.nuke/build.schema.json b/Build/.nuke/build.schema.json index 6472f2a..bbfa7fb 100644 --- a/Build/.nuke/build.schema.json +++ b/Build/.nuke/build.schema.json @@ -245,11 +245,11 @@ "NewVersions": { "type": "boolean" }, - "NugetApiKey": { + "NuGetApiKey": { "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, - "NugetApiUrl": { + "NuGetApiUrl": { "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, @@ -295,7 +295,7 @@ "type": "string", "description": "Path to a solution file that is automatically loaded" }, - "UnlistNuget": { + "UnlistNuGet": { "type": "boolean" }, "VendorDescription": { diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e58acf..1bc5592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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.5.0] / 2025-01-22 +### Features +- Add `ricaun.Revit.DA` to fix issues. (Fix: #7) (Fix: #9) +### Updated +- Delete `Revit.DesignApplication` project. + ## [1.4.2] / 2025-01-16 ### Features - Add `ApplicationExtensions` to check `InAddInContext` and `InEventContext`. @@ -54,6 +60,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - First Release [vNext]: ../../compare/1.0.0...HEAD +[1.5.0]: ../../compare/1.4.2...1.5.0 [1.4.2]: ../../compare/1.4.1...1.4.2 [1.4.1]: ../../compare/1.4.0...1.4.1 [1.4.0]: ../../compare/1.3.1...1.4.0 diff --git a/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip b/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip index 9708d06..734066f 100644 Binary files a/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip and b/DesignAutomationConsole/Bundle/RevitAddin.DA.Tester.bundle.zip differ diff --git a/Directory.Build.props b/Directory.Build.props index 7fffec1..019c277 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 1.4.2 + 1.5.0 \ No newline at end of file diff --git a/README.md b/README.md index 6b506f8..517fe7a 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ public class OutputModel } ``` +## References + +This project uses the following libraries: +* [ricaun.Revit.DA](https://github.com/ricaun-io/ricaun.Revit.DA) - Design Automation for Revit library utility. +* [Autodesk.Forge.Oss.DesignAutomation](https://github.com/ricaun-io/forge-api-dotnet-oss.design.automation) - Run Design Automation with OSS library in C#. + ## Installation * Download bundle version [RevitAddin.DA.Tester.bundle.zip](../../releases/latest/download/RevitAddin.DA.Tester.bundle.zip) diff --git a/Revit.DesignApplication/DesignApplication.cs b/Revit.DesignApplication/DesignApplication.cs deleted file mode 100644 index a91b5ab..0000000 --- a/Revit.DesignApplication/DesignApplication.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Autodesk.Revit.ApplicationServices; -using Autodesk.Revit.DB; -using DesignAutomationFramework; -using System; - -namespace Revit.DesignApplication -{ - public abstract class DesignApplication : IExternalDBApplication, IDesignAutomation - { - public ControlledApplication Application { get; private set; } - public abstract void OnStartup(); - public abstract void OnShutdown(); - public abstract bool Execute(Application application, string filePath, Document document); - - private IExternalDBApplication designApplication; - public ExternalDBApplicationResult OnStartup(ControlledApplication application) - { - this.Application = application; - - designApplication = DesignApplicationLoader.LoadVersion(this); - - if (designApplication is IExternalDBApplication) - { - return designApplication.OnStartup(application); - } - - Console.WriteLine("----------------------------------------"); - Console.WriteLine($"FullName: \t{this.GetType().Assembly.FullName}"); - Console.WriteLine($"AddInName: \t{this.Application.ActiveAddInId?.GetAddInName()}"); - Console.WriteLine("----------------------------------------"); - - OnStartup(); - DesignAutomationBridge.DesignAutomationReadyEvent += DesignAutomationReadyEvent; - - return ExternalDBApplicationResult.Succeeded; - } - - public ExternalDBApplicationResult OnShutdown(ControlledApplication application) - { - this.Application = application; - - if (designApplication is IExternalDBApplication) - { - try - { - return designApplication.OnShutdown(application); - } - finally - { - DesignApplicationLoader.Dispose(); - } - } - - OnShutdown(); - DesignAutomationBridge.DesignAutomationReadyEvent -= DesignAutomationReadyEvent; - - return ExternalDBApplicationResult.Succeeded; - } - - - private void DesignAutomationReadyEvent(object sender, DesignAutomationReadyEventArgs e) - { - DesignAutomationBridge.DesignAutomationReadyEvent -= DesignAutomationReadyEvent; - - var data = e.DesignAutomationData; - - Console.WriteLine("--------------------------------------------------"); - Console.WriteLine($"RevitApp: {data.RevitApp} \tFilePath: {data.FilePath} \tRevitDoc: {data.RevitDoc} \tAddInName:{data.RevitApp.ActiveAddInId?.GetAddInName()}"); - Console.WriteLine("--------------------------------------------------"); - - e.Succeeded = Execute(data.RevitApp, data.FilePath, data.RevitDoc); - } - } -} \ No newline at end of file diff --git a/Revit.DesignApplication/DesignApplicationLoader.cs b/Revit.DesignApplication/DesignApplicationLoader.cs deleted file mode 100644 index b9e1ebc..0000000 --- a/Revit.DesignApplication/DesignApplicationLoader.cs +++ /dev/null @@ -1,87 +0,0 @@ -using Autodesk.Revit.DB; -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Versioning; - -namespace Revit.DesignApplication -{ - internal static class DesignApplicationLoader - { - private static Assembly loadAssembly; - public static IExternalDBApplication LoadVersion(T designApplication) where T : DesignApplication - { - var type = designApplication.GetType(); - - var similar = AppDomain.CurrentDomain.GetAssemblies().Where(e => e.FullName == type.Assembly.FullName); - if (similar.Count() >= 2) - { - return null; - } - - var location = type.Assembly.Location; - var revitAssemblyReference = type.Assembly.GetReferencedAssemblies().FirstOrDefault(e => e.Name.Equals("RevitAPI")); - var revitAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(e => e.GetName().Name.Equals("RevitAPI")); - - var revitReferenceVersion = revitAssemblyReference.Version.Major + 2000; - var revitVersion = revitAssembly.GetName().Version.Major + 2000; - - Console.WriteLine("--------------------------------------------------"); - Console.WriteLine($"DesignApplicationLoader: \t{revitVersion} -> {revitReferenceVersion}"); - - for (int version = revitVersion; version > revitReferenceVersion; version--) - { - var directory = Path.GetDirectoryName(location); - var directoryVersionRevit = Path.Combine(directory, "..", version.ToString()); - var fileName = Path.Combine(directoryVersionRevit, Path.GetFileName(location)); - - //Console.WriteLine($"DesignApplicationLoader Try: \t{version}"); - - if (File.Exists(fileName)) - { - fileName = new FileInfo(fileName).FullName; - Console.WriteLine($"DesignApplicationLoader File Exists: \t{fileName}"); - Console.WriteLine($"DesignApplicationLoader Version: \t{version}"); - Console.WriteLine($"DesignApplicationLoader LoadFile: \t{Path.GetFileName(fileName)}"); - AppDomain.CurrentDomain.AssemblyResolve += LoadAssemblyResolve; - loadAssembly = Assembly.LoadFile(fileName); - break; - } - } - - Console.WriteLine("----------------------------------------"); - - if (loadAssembly is not null) - { - var loadType = loadAssembly.GetType(type.FullName); - - Console.WriteLine($"DesignApplicationLoader Type: {loadType}"); - Console.WriteLine($"DesignApplicationLoader FrameworkName: \t{loadType.Assembly.GetCustomAttribute()?.FrameworkName}"); - Console.WriteLine("----------------------------------------"); - - return Activator.CreateInstance(loadType) as IExternalDBApplication; - } - - return null; - } - - private static Assembly LoadAssemblyResolve(object sender, ResolveEventArgs args) - { - var assemblyName = new AssemblyName(args.Name); - var assemblyPath = Path.Combine(Path.GetDirectoryName(loadAssembly.Location), assemblyName.Name + ".dll"); - if (File.Exists(assemblyPath)) - { - var folderName = Path.GetFileName(Path.GetDirectoryName(assemblyPath)); - Console.WriteLine($"AssemblyResolve LoadFile: {folderName}\\{assemblyName.Name + ".dll"}"); - return Assembly.LoadFile(assemblyPath); - } - return null; - } - - public static void Dispose() - { - AppDomain.CurrentDomain.AssemblyResolve -= LoadAssemblyResolve; - } - } -} \ No newline at end of file diff --git a/Revit.DesignApplication/IDesignAutomation.cs b/Revit.DesignApplication/IDesignAutomation.cs deleted file mode 100644 index e8df580..0000000 --- a/Revit.DesignApplication/IDesignAutomation.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Autodesk.Revit.ApplicationServices; -using Autodesk.Revit.DB; - -namespace Revit.DesignApplication -{ - public interface IDesignAutomation - { - bool Execute(Application application, string filePath, Document document); - } -} \ No newline at end of file diff --git a/Revit.DesignApplication/Revit.DesignApplication.csproj b/Revit.DesignApplication/Revit.DesignApplication.csproj deleted file mode 100644 index c860d9c..0000000 --- a/Revit.DesignApplication/Revit.DesignApplication.csproj +++ /dev/null @@ -1,66 +0,0 @@ - - - - Library - latest - - - - - net47;net48;net8.0-windows - true - None - - - - - 2017 - - - - - 2019 - - - - - 2021 - - - - - 2025 - - - - - - - true - true - false - - - - - true - bin\Release\$(RevitVersion) - REVIT$(RevitVersion) - MSB3052 - None - - - - - true - bin\Debug\ - DEBUG;TRACE;REVIT$(RevitVersion) - Full - - - - - - - - diff --git a/RevitAddin.DA.Tester.sln b/RevitAddin.DA.Tester.sln index 81427e3..4dfe449 100644 --- a/RevitAddin.DA.Tester.sln +++ b/RevitAddin.DA.Tester.sln @@ -17,8 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution", "Solution", "{64 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DesignAutomationConsole", "DesignAutomationConsole\DesignAutomationConsole.csproj", "{7F41BE81-4EFB-4FAC-8563-B5EDAEA9F44B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Revit.DesignApplication", "Revit.DesignApplication\Revit.DesignApplication.csproj", "{0966B1C7-6ECE-44D0-A71B-7C26EB598BFF}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -35,10 +33,6 @@ Global {7F41BE81-4EFB-4FAC-8563-B5EDAEA9F44B}.Debug|Any CPU.Build.0 = Debug|Any CPU {7F41BE81-4EFB-4FAC-8563-B5EDAEA9F44B}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F41BE81-4EFB-4FAC-8563-B5EDAEA9F44B}.Release|Any CPU.Build.0 = Release|Any CPU - {0966B1C7-6ECE-44D0-A71B-7C26EB598BFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0966B1C7-6ECE-44D0-A71B-7C26EB598BFF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0966B1C7-6ECE-44D0-A71B-7C26EB598BFF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0966B1C7-6ECE-44D0-A71B-7C26EB598BFF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RevitAddin.DA.Tester/Revit/App.cs b/RevitAddin.DA.Tester/Revit/App.cs index cf6c552..ab84c93 100644 --- a/RevitAddin.DA.Tester/Revit/App.cs +++ b/RevitAddin.DA.Tester/Revit/App.cs @@ -1,6 +1,6 @@ using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.DB; -using Revit.DesignApplication; +using ricaun.Revit.DA; using RevitAddin.DA.Tester.Services; using System; @@ -16,9 +16,9 @@ public override void OnStartup() Console.WriteLine("----------------------------------------"); Console.WriteLine($"Location: {this.GetType().Assembly.Location}"); Console.WriteLine("----------------------------------------"); - Console.WriteLine($"AddInName: \t{Application.ActiveAddInId?.GetAddInName()}"); + Console.WriteLine($"AddInName: \t{ControlledApplication.ActiveAddInId?.GetAddInName()}"); Console.WriteLine("----------------------------------------"); - Application.ApplicationInitialized += Application_ApplicationInitialized; + ControlledApplication.ApplicationInitialized += Application_ApplicationInitialized; } private void Application_ApplicationInitialized(object sender, Autodesk.Revit.DB.Events.ApplicationInitializedEventArgs e) @@ -27,10 +27,6 @@ private void Application_ApplicationInitialized(object sender, Autodesk.Revit.DB AddInName = application.ActiveAddInId?.GetAddInName(); } - public override void OnShutdown() - { - - } public override bool Execute(Application application, string filePath, Document document) { return new DesignAutomationController().Execute(application, filePath, document); diff --git a/RevitAddin.DA.Tester/RevitAddin.DA.Tester.csproj b/RevitAddin.DA.Tester/RevitAddin.DA.Tester.csproj index 291ea40..1aa14b5 100644 --- a/RevitAddin.DA.Tester/RevitAddin.DA.Tester.csproj +++ b/RevitAddin.DA.Tester/RevitAddin.DA.Tester.csproj @@ -127,14 +127,11 @@ + - - - - True