diff --git a/CHANGELOG.md b/CHANGELOG.md index cd3d7c0..1bc5592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [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 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 - - - - - - - -