|
@@ -3,18 +3,15 @@
|
|
|
* 创 建 者:Garrett
|
|
|
* 创建日期:2019/6/27 11:10:20
|
|
|
* ==============================================================================*/
|
|
|
+using Autodesk.Revit;
|
|
|
+using Autodesk.Revit.ApplicationServices;
|
|
|
+using Autodesk.Revit.DB;
|
|
|
+using SAGA.DotNetUtils.Revit;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
|
-using System.Net.Mime;
|
|
|
using System.Reflection;
|
|
|
-using System.Text;
|
|
|
-using System.Threading.Tasks;
|
|
|
-using Autodesk.Revit;
|
|
|
-using Autodesk.Revit.ApplicationServices;
|
|
|
-using Autodesk.Revit.DB;
|
|
|
-using Autodesk.RevitAddIns;
|
|
|
|
|
|
namespace ExportStart
|
|
|
{
|
|
@@ -22,7 +19,20 @@ namespace ExportStart
|
|
|
{
|
|
|
// 此路径为动态反射搜索路径 、 此路径可为任意路径(只要路径下有RevitNET 所需依赖项即可,完整依赖项可在 Naviswork 2016 下面找到)
|
|
|
|
|
|
- static readonly string[] Searchs = RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToArray();
|
|
|
+ private static readonly string[] Searchs = GetRevitProductPath();
|
|
|
+ //new[] { @"E:\Program Files\Autodesk\Revit 2017" };
|
|
|
+ //new []{ @"E:\Program Files\Autodesk\Revit 2018" };
|
|
|
+ /// <summary>
|
|
|
+ /// 选择版本时,预先将版本信息写在RevitFileVision.txt文件中
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ static string[] GetRevitProductPath()
|
|
|
+ {
|
|
|
+ //保存版本号
|
|
|
+ var vision = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, StarterConst.RevitFileVisionFile));
|
|
|
+ var revitVision = $"Revit {vision}";
|
|
|
+ return RevitProductUtility.GetAllInstalledRevitProducts().Where(t => Directory.GetParent(t).Name == revitVision).ToArray();
|
|
|
+ }
|
|
|
|
|
|
static readonly object lockobj = new object();
|
|
|
|
|
@@ -86,14 +96,16 @@ namespace ExportStart
|
|
|
private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
|
|
|
{
|
|
|
var assemblyName = new AssemblyName(args.Name);
|
|
|
-
|
|
|
+ //File.AppendAllText(@"E:\startlog.txt","args:"+ args.Name + "\r\n");
|
|
|
foreach (var item in Searchs)
|
|
|
{
|
|
|
var file = string.Format("{0}.dll", System.IO.Path.Combine(item, assemblyName.Name));
|
|
|
|
|
|
if (File.Exists(file))
|
|
|
{
|
|
|
- NeedAssemblys.Add(assemblyName.Name);
|
|
|
+ AddAssemblys(assemblyName.Name);
|
|
|
+ //File.Copy(file,Path.Combine(@"D:\Revit\RevitExport\JBIM\OutputDll\2018",assemblyName.Name+".dll"),true);
|
|
|
+
|
|
|
return Assembly.LoadFile(file);
|
|
|
}
|
|
|
}
|
|
@@ -102,10 +114,11 @@ namespace ExportStart
|
|
|
}
|
|
|
public static List<string> NeedAssemblys = new List<string>();
|
|
|
|
|
|
- public static void PrintAllAssemblys()
|
|
|
+ public static void AddAssemblys(string str)
|
|
|
{
|
|
|
- string str = string.Join("\r\n", NeedAssemblys);
|
|
|
- Console.WriteLine(str);
|
|
|
+ if(!NeedAssemblys.Contains(str))
|
|
|
+ NeedAssemblys.Add(str);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|