mengxiangge il y a 5 ans
Parent
commit
4fde336c8a
36 fichiers modifiés avec 321 ajouts et 149 suppressions
  1. 2 0
      .gitignore
  2. 0 4
      Dispatcher/Client/Client.csproj
  3. 1 1
      Dispatcher/Client/Start/RevitCmdExecutor.cs
  4. 0 4
      Executer/DataCheck/Extend/ElementExtend.cs
  5. 4 3
      Executer/DataCheck/ServiceDataCheck.csproj
  6. 6 7
      Executer/DataExport/RevitExport/RevitExport.csproj
  7. 4 4
      Executer/DataExport/RevitToJBim/MbiExport.cs
  8. 4 7
      Executer/DataExport/RevitToJBim/RevitToJBim.csproj
  9. BIN
      Executer/Dlls/SAGA.DotNetUtils.dll
  10. BIN
      Executer/Dlls/SAGA.RevitAPI.dll
  11. BIN
      Executer/Dlls/SAGA.RevitUtils.dll
  12. 1 1
      Executer/MBIRevitBase/MBIRevitBase.csproj
  13. 0 3
      RevitDlls/.gitignore
  14. 0 0
      RevitDlls/RevitAPI.dll
  15. 0 0
      RevitDlls/RevitNET.dll
  16. BIN
      RevitDlls/SAGA.DotNetUtils.dll
  17. BIN
      RevitDlls/SAGA.Models.dll
  18. BIN
      RevitDlls/SAGA.RevitUtils.dll
  19. 22 11
      ServiceRevit.sln
  20. 6 0
      Starter/ExportStart.csproj.user
  21. 0 60
      Starter/RevitVisionUtil.cs
  22. 84 0
      Starter/StartVisionSelector/Program.cs
  23. 36 0
      Starter/StartVisionSelector/Properties/AssemblyInfo.cs
  24. 27 0
      Starter/StartVisionSelector/SelectorConst.cs
  25. 54 0
      Starter/StartVisionSelector/StartVisionSelector.csproj
  26. 6 0
      Starter/StartVisionSelector/StartVisionSelector.csproj.user
  27. 0 0
      Starter/Starter/App.config
  28. 0 0
      Starter/Starter/DocumentExtension.cs
  29. 8 12
      Starter/ExportStart.csproj
  30. 6 0
      Starter/Starter/ExportStart.csproj.user
  31. 5 12
      Starter/Program.cs
  32. 0 0
      Starter/Starter/Properties/AssemblyInfo.cs
  33. 3 1
      Starter/ReadMe.txt
  34. 14 14
      Starter/RevitCoreContext.cs
  35. 6 5
      Starter/RevitUtils.cs
  36. 22 0
      Starter/Starter/StarterConst.cs

+ 2 - 0
.gitignore

@@ -22,3 +22,5 @@
 /Starter/bin
 /Starter/obj
 /Executer/MBIRevitBase/obj/Debug
+/Starter/Starter/obj/Debug
+/Starter/StartVisionSelector/obj/Debug

+ 0 - 4
Dispatcher/Client/Client.csproj

@@ -74,10 +74,6 @@
     <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
       <HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
     </Reference>
-    <Reference Include="SAGA.DotNetUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Dlls\SAGA.DotNetUtils.dll</HintPath>
-    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
       <HintPath>..\packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll</HintPath>

+ 1 - 1
Dispatcher/Client/Start/RevitCmdExecutor.cs

@@ -24,7 +24,7 @@ namespace Client.Start
             //实体类传入参数、参考楼层列表
             //执行方法,返回执行结果 
             Console.WriteLine(DateTime.Now+" 准备执行命令:"+revitCmd);
-            string fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");
+            string fullPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StartVisionSelector.exe");
             Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory +
             process.StartInfo.FileName = fullPath;//执行的exe路径
             process.StartInfo.UseShellExecute = false;//不显示shell

+ 0 - 4
Executer/DataCheck/Extend/ElementExtend.cs

@@ -212,10 +212,6 @@ namespace ServiceRevitLib.Extend
                         break;
                     }
                 }
-            }else if (element is Wall wall)
-            {
-                if (wall.IsCurtaiWall())
-                    space = null;
             }
 
             return space;

+ 4 - 3
Executer/DataCheck/ServiceDataCheck.csproj

@@ -55,15 +55,16 @@
     </Reference>
     <Reference Include="RevitAPI, Version=17.0.0.0, Culture=neutral, processorArchitecture=AMD64">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Dlls\RevitAPI.dll</HintPath>
+      <HintPath>..\..\RevitDlls\RevitAPI.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="SAGA.DotNetUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Dlls\SAGA.DotNetUtils.dll</HintPath>
+      <HintPath>..\..\RevitDlls\SAGA.DotNetUtils.dll</HintPath>
     </Reference>
     <Reference Include="SAGA.RevitUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Dlls\SAGA.RevitUtils.dll</HintPath>
+      <HintPath>..\..\RevitDlls\SAGA.RevitUtils.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />

+ 6 - 7
Executer/DataExport/RevitExport/RevitExport.csproj

@@ -31,14 +31,13 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="RevitAPI">
-      <HintPath>..\Dlls\RevitAPI.dll</HintPath>
+    <Reference Include="RevitAPI, Version=17.0.0.0, Culture=neutral, processorArchitecture=AMD64">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\RevitDlls\RevitAPI.dll</HintPath>
     </Reference>
-    <Reference Include="RevitAPIUI">
-      <HintPath>..\Dlls\RevitAPIUI.dll</HintPath>
-    </Reference>
-    <Reference Include="SAGA.RevitUtils">
-      <HintPath>..\Dlls\SAGA.RevitUtils.dll</HintPath>
+    <Reference Include="SAGA.RevitUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\..\RevitDlls\SAGA.RevitUtils.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />

+ 4 - 4
Executer/DataExport/RevitToJBim/MbiExport.cs

@@ -40,10 +40,10 @@ namespace RevitToJBim
                  */
                 var result = BimJsonUtil.Serializer(mbiDocument);
                 var resultResponse = UploadService.UploadExportFile(result);
-                //string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
-                //string path = Path.Combine(@"D:\", $"{fileName}.json");
-                //File.WriteAllText(path, resultResponse.ToString());
-                //System.Diagnostics.Process.Start("notepad.exe", path);
+                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
+                string path = Path.Combine(@"D:\", $"{fileName}.json");
+                File.WriteAllText(path, resultResponse.ToString());
+                System.Diagnostics.Process.Start("notepad.exe", path);
             }
             catch (Exception ex)
             {

+ 4 - 7
Executer/DataExport/RevitToJBim/RevitToJBim.csproj

@@ -36,19 +36,16 @@
     </Reference>
     <Reference Include="RevitAPI, Version=17.0.0.0, Culture=neutral, processorArchitecture=AMD64">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\Dlls\RevitAPI.dll</HintPath>
+      <HintPath>..\..\..\RevitDlls\RevitAPI.dll</HintPath>
+      <Private>False</Private>
     </Reference>
     <Reference Include="SAGA.DotNetUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\Dlls\SAGA.DotNetUtils.dll</HintPath>
-    </Reference>
-    <Reference Include="SAGA.RevitAPI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\Dlls\SAGA.RevitAPI.dll</HintPath>
+      <HintPath>..\..\..\RevitDlls\SAGA.DotNetUtils.dll</HintPath>
     </Reference>
     <Reference Include="SAGA.RevitUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\Dlls\SAGA.RevitUtils.dll</HintPath>
+      <HintPath>..\..\..\RevitDlls\SAGA.RevitUtils.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />

BIN
Executer/Dlls/SAGA.DotNetUtils.dll


BIN
Executer/Dlls/SAGA.RevitAPI.dll


BIN
Executer/Dlls/SAGA.RevitUtils.dll


+ 1 - 1
Executer/MBIRevitBase/MBIRevitBase.csproj

@@ -17,7 +17,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\..\..\OutputDll\</OutputPath>
+    <OutputPath>..\..\OutputDll\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 0 - 3
RevitDlls/.gitignore

@@ -1,3 +0,0 @@
-# ignore all except .gitignore file
-*
-!.gitignore

Executer/Dlls/RevitAPI.dll → RevitDlls/RevitAPI.dll


Executer/Dlls/RevitNET.dll → RevitDlls/RevitNET.dll


BIN
RevitDlls/SAGA.DotNetUtils.dll


BIN
RevitDlls/SAGA.Models.dll


BIN
RevitDlls/SAGA.RevitUtils.dll


+ 22 - 11
ServiceRevit.sln

@@ -29,12 +29,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RevitExport", "Executer\Dat
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDataCheck", "Executer\DataCheck\ServiceDataCheck.csproj", "{7B748B09-DC20-4406-85A3-101E7833F8CE}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportStart", "Starter\ExportStart.csproj", "{003C65AE-6802-4142-97FE-611C23E3676D}"
-EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ServiceBase", "ServiceBase", "{A43679EA-F1D9-4B7B-B2CD-4C505BD6E3FA}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBIRevitBase", "Executer\MBIRevitBase\MBIRevitBase.csproj", "{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportStart", "Starter\Starter\ExportStart.csproj", "{003C65AE-6802-4142-97FE-611C23E3676D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartVisionSelector", "Starter\StartVisionSelector\StartVisionSelector.csproj", "{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -107,14 +109,6 @@ Global
 		{7B748B09-DC20-4406-85A3-101E7833F8CE}.Release|Any CPU.Build.0 = Release|Any CPU
 		{7B748B09-DC20-4406-85A3-101E7833F8CE}.Release|x64.ActiveCfg = Release|Any CPU
 		{7B748B09-DC20-4406-85A3-101E7833F8CE}.Release|x64.Build.0 = Release|Any CPU
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|x64.ActiveCfg = Debug|x64
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|x64.Build.0 = Debug|x64
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|Any CPU.Build.0 = Release|Any CPU
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|x64.ActiveCfg = Release|x64
-		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|x64.Build.0 = Release|x64
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -123,6 +117,22 @@ Global
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}.Release|Any CPU.Build.0 = Release|Any CPU
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}.Release|x64.ActiveCfg = Release|Any CPU
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87}.Release|x64.Build.0 = Release|Any CPU
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|x64.ActiveCfg = Debug|x64
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Debug|x64.Build.0 = Debug|x64
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|Any CPU.Build.0 = Release|Any CPU
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|x64.ActiveCfg = Release|x64
+		{003C65AE-6802-4142-97FE-611C23E3676D}.Release|x64.Build.0 = Release|x64
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Debug|x64.Build.0 = Debug|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Release|x64.ActiveCfg = Release|Any CPU
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}.Release|x64.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -138,9 +148,10 @@ Global
 		{F83397D2-C35A-4F5C-8DAF-E9DE1E2D2AD5} = {CC1C66EB-A37B-4A52-9E04-C2EBAAE30261}
 		{825B43F4-1F7B-44AC-9BD4-501DE9422D32} = {CC1C66EB-A37B-4A52-9E04-C2EBAAE30261}
 		{7B748B09-DC20-4406-85A3-101E7833F8CE} = {2EFD8011-8252-42D5-8F94-57AC4DEACF59}
-		{003C65AE-6802-4142-97FE-611C23E3676D} = {F38C0379-6B8D-4DCF-80CA-1DA3FC82728E}
 		{A43679EA-F1D9-4B7B-B2CD-4C505BD6E3FA} = {2DEE1AC7-A829-4AF7-B26E-A6A69EA1A3CB}
 		{2BC3DA7B-57CB-4D9D-8AFA-888EA4D8DA87} = {A43679EA-F1D9-4B7B-B2CD-4C505BD6E3FA}
+		{003C65AE-6802-4142-97FE-611C23E3676D} = {F38C0379-6B8D-4DCF-80CA-1DA3FC82728E}
+		{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0} = {F38C0379-6B8D-4DCF-80CA-1DA3FC82728E}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {0B809618-4643-4968-B822-625AF12CDCA0}

+ 6 - 0
Starter/ExportStart.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ProjectFiles</ProjectView>
+  </PropertyGroup>
+</Project>

+ 0 - 60
Starter/RevitVisionUtil.cs

@@ -1,60 +0,0 @@
-/* ==============================================================================
- * 功能描述:RevitVisionUtil  
- * 创 建 者:Garrett
- * 创建日期:2019/6/28 9:25:34
- * ==============================================================================*/
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace ExportStart
-{
-    /// <summary>
-    /// RevitVisionUtil
-    /// </summary>
-    public class RevitVisionUtil
-    {
-        /// <summary>
-        /// 获取Revit文件的版本
-        /// </summary>
-        /// <param name="path">文件路径</param>
-        /// <returns></returns>
-        public static string GetRevitVision(string path)
-        {
-            string revitVision = null;
-            FileStream stream = new FileStream(path, FileMode.Open);
-
-            int size = 1024 * 1024;
-            byte[] bytes = new byte[size];
-
-            
-            while (stream.Read(bytes, 0, size) > 0)
-            {
-                string str = Encoding.Unicode.GetString(bytes);
-                //if (str.Contains("2014"))
-                //{
-                //    revitVision = "2014";
-
-                //    File.WriteAllText(@"D:\abc.txt", str);
-                //    System.Diagnostics.Process.Start("notepad.exe", path);
-                //    break;
-                //}
-
-                string pattern = @"Autodesk Revit \d{4}";
-                var match = Regex.Match(str, pattern);
-                if (match.Success)
-                {
-                    revitVision = match.Value.Substring(match.Length - 4, 4);
-
-                    //File.WriteAllText(@"D:\abc.txt", str);
-                    break;
-                }
-            }
-            return revitVision;
-        }
-    }
-}

+ 84 - 0
Starter/StartVisionSelector/Program.cs

@@ -0,0 +1,84 @@
+using SAGA.DotNetUtils.Revit;
+using System;
+using System.Diagnostics;
+using System.IO;
+
+namespace StartVisionSelector
+{
+    public class Program
+    {
+
+        public static void Main(string[] args)
+        {
+            string command = null;
+            string path = null;
+            if (args.Length > 0)
+            {
+                command = args[0];
+            }
+            if (args.Length > 1)
+            {
+                path = args[1];
+            }
+#if DEBUG
+            if (string.IsNullOrWhiteSpace(command))
+            {
+                command = "DataExport";
+                path = @"E:\导出测试\testR17.rvt";
+                //path = @"E:\导出测试\testR18.rvt";
+                //path = @"E:\导出测试\testR16.rvt";
+            }
+
+#endif
+
+
+            Console.WriteLine("start");
+            #region 保存版本号
+
+            //保存版本号
+            var runPath = AppDomain.CurrentDomain.BaseDirectory;
+            var revitVision = RevitVisionUtil.GetRevitVision(path);
+            File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SelectorConst.RevitFileVisionFile), revitVision);
+
+            #endregion
+
+            #region 删除生成的Revit dll
+
+            var dllsPath = Path.Combine(Directory.GetParent(runPath).Parent.FullName, "Dlls");
+            var loadingRevitPath = Path.Combine(dllsPath, SelectorConst.LoadingRevit);
+
+            //先删除,后Copy,如果可以指定Revit的安装目录,不需要Copy
+            #region Del RevitDll
+
+            foreach (string loadingItem in File.ReadAllLines(loadingRevitPath))
+            {
+                string destFile = Path.Combine(runPath, $"{loadingItem}.dll");
+                if(File.Exists(destFile))
+                    File.Delete(destFile);
+            }
+
+            #endregion
+            
+            #endregion
+            
+            #region 启动
+
+            Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory +
+            process.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");//执行的exe路径
+            process.StartInfo.UseShellExecute = false;//不显示shell
+            process.StartInfo.CreateNoWindow = true;//不创建窗口
+            process.StartInfo.RedirectStandardInput = true;//打开流输入
+            process.StartInfo.RedirectStandardOutput = true;//打开流输出
+            process.StartInfo.RedirectStandardError = true;//打开错误流
+            process.StartInfo.Arguments = "" + command + " \"" + path + "\"";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
+            process.Start();//执行
+            string msg = process.StandardOutput.ReadToEnd();//读取输出
+            process.WaitForExit();//等待执行完成
+            process.Close();//结束
+
+            #endregion
+            Console.WriteLine("end");
+            //Console.ReadKey();
+        }
+    }
+}

+ 36 - 0
Starter/StartVisionSelector/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("StartVisionSelector")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("StartVisionSelector")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("483cb146-0c1d-4865-ad34-fb0bbffde4d0")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 27 - 0
Starter/StartVisionSelector/SelectorConst.cs

@@ -0,0 +1,27 @@
+/* ==============================================================================
+ * 功能描述:SelectorConst  
+ * 创 建 者:Garrett
+ * 创建日期:2019/8/1 8:57:34
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StartVisionSelector
+{
+    /// <summary>
+    /// SelectorConst
+    /// </summary>
+    class SelectorConst
+    {
+        //Revit文件版本信息存储的位置
+        public const string RevitFileVisionFile = "RevitFileVision.txt";
+        /// <summary>
+        /// 程序集加载失败的dll
+        /// </summary>
+        public const string LoadingRevit = "LoadingRevitDll.txt";
+        
+    }
+}

+ 54 - 0
Starter/StartVisionSelector/StartVisionSelector.csproj

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{483CB146-0C1D-4865-AD34-FB0BBFFDE4D0}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>StartVisionSelector</RootNamespace>
+    <AssemblyName>StartVisionSelector</AssemblyName>
+    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>..\..\OutputDll\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup>
+    <StartupObject />
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="SAGA.DotNetUtils">
+      <HintPath>..\..\RevitDlls\SAGA.DotNetUtils.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="SelectorConst.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>

+ 6 - 0
Starter/StartVisionSelector/StartVisionSelector.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ProjectFiles</ProjectView>
+  </PropertyGroup>
+</Project>

Starter/App.config → Starter/Starter/App.config


Starter/DocumentExtension.cs → Starter/Starter/DocumentExtension.cs


+ 8 - 12
Starter/ExportStart.csproj

@@ -18,7 +18,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>..\OutputDll\</OutputPath>
+    <OutputPath>..\..\OutputDll\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -41,20 +41,16 @@
     <OutputPath>bin\x64\Release\</OutputPath>
   </PropertyGroup>
   <ItemGroup>
-    <Reference Include="RevitAddInUtility">
-      <HintPath>Dlls\RevitAddInUtility.dll</HintPath>
-    </Reference>
     <Reference Include="RevitAPI">
-      <HintPath>Dlls\RevitAPI.dll</HintPath>
+      <HintPath>..\..\RevitDlls\RevitAPI.dll</HintPath>
       <Private>False</Private>
     </Reference>
     <Reference Include="RevitNET">
-      <HintPath>Dlls\RevitNET.dll</HintPath>
+      <HintPath>..\..\RevitDlls\RevitNET.dll</HintPath>
       <Private>False</Private>
     </Reference>
-    <Reference Include="SAGA.DotNetUtils, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>Dlls\SAGA.DotNetUtils.dll</HintPath>
+    <Reference Include="SAGA.DotNetUtils">
+      <HintPath>..\..\RevitDlls\SAGA.DotNetUtils.dll</HintPath>
     </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
@@ -71,17 +67,17 @@
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RevitCoreContext.cs" />
     <Compile Include="RevitUtils.cs" />
-    <Compile Include="RevitVisionUtil.cs" />
+    <Compile Include="StarterConst.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="App.config" />
   </ItemGroup>
   <ItemGroup>
-    <ProjectReference Include="..\Executer\DataExport\RevitToJBim\RevitToJBim.csproj">
+    <ProjectReference Include="..\..\Executer\DataExport\RevitToJBim\RevitToJBim.csproj">
       <Project>{f83397d2-c35a-4f5c-8daf-e9de1e2d2ad5}</Project>
       <Name>RevitToJBim</Name>
     </ProjectReference>
-    <ProjectReference Include="..\Executer\DataCheck\ServiceDataCheck.csproj">
+    <ProjectReference Include="..\..\Executer\DataCheck\ServiceDataCheck.csproj">
       <Project>{7b748b09-dc20-4406-85a3-101e7833f8ce}</Project>
       <Name>ServiceDataCheck</Name>
     </ProjectReference>

+ 6 - 0
Starter/Starter/ExportStart.csproj.user

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <ProjectView>ShowAllFiles</ProjectView>
+  </PropertyGroup>
+</Project>

+ 5 - 12
Starter/Program.cs

@@ -1,14 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-using Autodesk.Revit.DB;
-using Autodesk.Revit.DB.Mechanical;
-using Autodesk.RevitAddIns;
+using Autodesk.Revit.DB;
 using ServiceRevitLib;
+using System;
+using System.IO;
 
 //using RevitToJBim.Common;
 
@@ -39,7 +32,7 @@ namespace ExportStart
                 command = "DataExport";
                 path = @"E:\导出测试\test.rvt";
             }
-          
+
 #endif
             if (string.IsNullOrEmpty(command))
             {
@@ -47,7 +40,7 @@ namespace ExportStart
             }
             Console.WriteLine(command);
             Console.WriteLine(path);
-            if (File.Exists(path)&&Enum.TryParse(command, out CommandType commandType))
+            if (File.Exists(path) && Enum.TryParse(command, out CommandType commandType))
             {
                 var app = RevitCoreContext.Instance.Application;
                 var doc = app.OpenDocumentFile(path);

Starter/Properties/AssemblyInfo.cs → Starter/Starter/Properties/AssemblyInfo.cs


+ 3 - 1
Starter/ReadMe.txt

@@ -2,4 +2,6 @@
 Main方法加[STAThread]标记
 平台目标 当前项目改为:X64
 目标框架 注意与引用的项目一致
-注意RevitAPIUI.dll可能会出错
+注意RevitAPIUI.dll可能会出错
+
+使用前需要安装Revit所需要的版本(Revit2018,Revit2019)

+ 14 - 14
Starter/RevitCoreContext.cs

@@ -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,7 @@ namespace ExportStart
     {
         // 此路径为动态反射搜索路径 、 此路径可为任意路径(只要路径下有RevitNET 所需依赖项即可,完整依赖项可在 Naviswork 2016 下面找到)
 
-        static readonly string[] Searchs = RevitUtils.GetSearchPath().ToArray();// RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToArray();
+        private static readonly string[] Searchs = RevitUtils.GetSearchPath().ToArray();
 
         static readonly object lockobj = new object();
 
@@ -86,15 +83,17 @@ 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);
-                    return Assembly.LoadFrom(file);
+                    AddAssemblys(assemblyName.Name);
+                    //File.Copy(file,Path.Combine(@"D:\Revit\RevitExport\JBIM\OutputDll\2018",assemblyName.Name+".dll"),true);
+
+                    return Assembly.LoadFile(file);
                 }
             }
 
@@ -102,10 +101,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);
         }
+
     }
 }

+ 6 - 5
Starter/RevitUtils.cs

@@ -9,9 +9,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Autodesk.RevitAddIns;
+using SAGA.DotNetUtils.Revit;
 
 namespace ExportStart
 {
@@ -23,8 +21,11 @@ namespace ExportStart
         /// <returns></returns>
         public static List<string> GetSearchPath()
         {
+            //选择版本时,预先将版本信息写在RevitFileVision.txt文件中,读取版本号
+            var vision = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, StarterConst.RevitFileVisionFile));
+            var revitVision = $"{vision}";
+            return SAGA.DotNetUtils.Revit.RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Item1==(revitVision)).Select(t => t.Item2).ToList();
 #if DEBUG
-         return   RevitProductUtility.GetAllInstalledRevitProducts().Where(t => t.Name == "Revit 2017").Select(x => x.InstallLocation).ToList();
 #else
          return new List<string>(){GetRevitDllPath()};
 #endif
@@ -44,7 +45,7 @@ namespace ExportStart
         }
 
         private static string m_RevitDllPath;
-        public static void SetRevitDllPath(string path)
+        public static void SetRevitkDllPath(string path)
         {
             m_RevitDllPath = path;
         } 

+ 22 - 0
Starter/Starter/StarterConst.cs

@@ -0,0 +1,22 @@
+/* ==============================================================================
+ * 功能描述:StarterConst  
+ * 创 建 者:Garrett
+ * 创建日期:2019/8/1 9:23:15
+ * ==============================================================================*/
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ExportStart
+{
+    /// <summary>
+    /// StarterConst
+    /// </summary>
+    class StarterConst
+    {      
+        //Revit文件版本信息存储的位置
+        public const string RevitFileVisionFile = "RevitFileVision.txt";
+    }
+}