浏览代码

xls:调整Start中项目的扩展性

xulisong 5 年之前
父节点
当前提交
6a50122a3d

+ 2 - 2
Executer/DataExport/RevitToJBim/RevitToJBim.csproj

@@ -31,8 +31,8 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-      <HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
+    <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\..\..\packages\Newtonsoft.Json.10.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
     <Reference Include="RevitAPI">
       <HintPath>..\Dlls\RevitAPI.dll</HintPath>

+ 1 - 1
Executer/DataExport/RevitToJBim/packages.config

@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="utf-8"?>
 <packages>
-  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
+  <package id="Newtonsoft.Json" version="10.0.1" targetFramework="net461" />
 </packages>

二进制
Starter/Dlls/RevitAddInUtility.dll


+ 3 - 0
Starter/ExportStart.csproj

@@ -46,9 +46,11 @@
     </Reference>
     <Reference Include="RevitAPI">
       <HintPath>Dlls\RevitAPI.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="RevitNET">
       <HintPath>Dlls\RevitNET.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="SAGA.DotNetUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
@@ -68,6 +70,7 @@
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RevitCoreContext.cs" />
+    <Compile Include="RevitUtils.cs" />
     <Compile Include="RevitVisionUtil.cs" />
   </ItemGroup>
   <ItemGroup>

+ 2 - 0
Starter/Program.cs

@@ -26,6 +26,8 @@ namespace ExportStart
             string command = args[0];
             string path = args[1];
 
+            //string command = "DataExport";
+            //string path = @"E:\导出测试\test.rvt";
             if (File.Exists(path)&&Enum.TryParse(command, out CommandType commandType))
             {
                 var app = RevitCoreContext.Instance.Application;

+ 3 - 3
Starter/RevitCoreContext.cs

@@ -22,7 +22,7 @@ namespace ExportStart
     {
         // 此路径为动态反射搜索路径 、 此路径可为任意路径(只要路径下有RevitNET 所需依赖项即可,完整依赖项可在 Naviswork 2016 下面找到)
 
-        static readonly string[] Searchs = RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToArray();
+        static readonly string[] Searchs = RevitUtils.GetSearchPath().ToArray();// RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToArray();
 
         static readonly object lockobj = new object();
 
@@ -93,8 +93,8 @@ namespace ExportStart
 
                 if (File.Exists(file))
                 {
-                    NeedAssemblys.Add(assemblyName.Name);
-                    return Assembly.LoadFile(file);
+                    //NeedAssemblys.Add(assemblyName.Name);
+                    return Assembly.LoadFrom(file);
                 }
             }
 

+ 53 - 0
Starter/RevitUtils.cs

@@ -0,0 +1,53 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:RevitUtils
+ * 作者:xulisong
+ * 创建时间: 2019/7/29 9:08:18
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Autodesk.RevitAddIns;
+
+namespace ExportStart
+{
+    public class RevitUtils
+    {
+        /// <summary>
+        /// 获取Revit搜索dll路径
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> GetSearchPath()
+        {
+#if DEBUG
+         return   RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToList();
+#else
+         return new List<string>(){GetRevitDllPath()};
+#endif
+        }
+        #region dll路径管理
+        /// <summary>
+        /// 获取RevitDll,所在目录
+        /// </summary>
+        /// <returns></returns>
+        public static string GetRevitDllPath()
+        {
+            if (!string.IsNullOrWhiteSpace(m_RevitDllPath))
+            {
+                return m_RevitDllPath;
+            }
+            return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\\RevitDlls");
+        }
+
+        private static string m_RevitDllPath;
+        public static void SetRevitDllPath(string path)
+        {
+            m_RevitDllPath = path;
+        } 
+        #endregion
+    }
+}