Program.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using SAGA.DotNetUtils.Revit;
  2. using System;
  3. using System.Diagnostics;
  4. using System.IO;
  5. namespace StartVisionSelector
  6. {
  7. public class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. string path = @"E:\导出测试\testR17.rvt";
  12. //path = @"E:\导出测试\testR18.rvt";
  13. //path = @"E:\导出测试\testR16.rvt";
  14. Console.WriteLine("start");
  15. #region 保存版本号
  16. //保存版本号
  17. var runPath = AppDomain.CurrentDomain.BaseDirectory;
  18. var revitVision = RevitVisionUtil.GetRevitVision(path);
  19. File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SelectorConst.RevitFileVisionFile), revitVision);
  20. #endregion
  21. #region 删除生成的Revit dll
  22. var dllsPath = Path.Combine(Directory.GetParent(runPath).Parent.FullName, "Dlls");
  23. var loadingRevitPath = Path.Combine(dllsPath, SelectorConst.LoadingRevit);
  24. //先删除,后Copy,如果可以指定Revit的安装目录,不需要Copy
  25. #region Del RevitDll
  26. foreach (string loadingItem in File.ReadAllLines(loadingRevitPath))
  27. {
  28. string destFile = Path.Combine(runPath, $"{loadingItem}.dll");
  29. if(File.Exists(destFile))
  30. File.Delete(destFile);
  31. }
  32. #endregion
  33. #endregion
  34. #region Copy RevitAddInUtility.dll
  35. //var revitAddInDll = revitdllDirectoryInfo.GetFiles(SelectorConst.RevitAddInUtilityDll);
  36. //if (revitAddInDll.Length != 0)
  37. // foreach (FileInfo fileInfo in revitAddInDll)
  38. // {
  39. // string destFile = Path.Combine(runPath, fileInfo.Name);
  40. // fileInfo.CopyTo(destFile, true);
  41. // }
  42. #endregion
  43. #region 启动
  44. Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory +
  45. process.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");//执行的exe路径
  46. process.StartInfo.UseShellExecute = false;//不显示shell
  47. process.StartInfo.CreateNoWindow = true;//不创建窗口
  48. process.StartInfo.RedirectStandardInput = true;//打开流输入
  49. process.StartInfo.RedirectStandardOutput = true;//打开流输出
  50. process.StartInfo.RedirectStandardError = true;//打开错误流
  51. process.StartInfo.Arguments = "\"" + path + "\"";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
  52. process.Start();//执行
  53. string msg = process.StandardOutput.ReadToEnd();//读取输出
  54. process.WaitForExit();//等待执行完成
  55. process.Close();//结束
  56. #endregion
  57. Console.WriteLine("end");
  58. //Console.ReadKey();
  59. }
  60. }
  61. }