Program.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Threading.Tasks;
  8. using Autodesk.Revit.DB;
  9. using Autodesk.Revit.DB.Mechanical;
  10. using Autodesk.RevitAddIns;
  11. using ServiceRevitLib;
  12. //using RevitToJBim.Common;
  13. namespace ExportStart
  14. {
  15. class Program
  16. {
  17. static Program()
  18. {
  19. RevitCoreContext.Instance.Run();
  20. }
  21. [STAThread]
  22. static void Main(string[] args)
  23. {
  24. string command = args[0];
  25. string path = args[1];
  26. //string command = "DataExport";
  27. //string path = @"E:\导出测试\test.rvt";
  28. if (File.Exists(path)&&Enum.TryParse(command, out CommandType commandType))
  29. {
  30. var app = RevitCoreContext.Instance.Application;
  31. var doc = app.OpenDocumentFile(path);
  32. switch (commandType)
  33. {
  34. case CommandType.DataCheck:
  35. Check(doc);
  36. break;
  37. case CommandType.DataExport:
  38. Export(doc);
  39. break;
  40. }
  41. RevitCoreContext.Instance.Stop();
  42. }
  43. }
  44. enum CommandType
  45. {
  46. None = 0,
  47. DataCheck,
  48. DataExport
  49. }
  50. public static void Export(Document doc)
  51. {
  52. try
  53. {
  54. Console.WriteLine("Start Export");
  55. RevitToJBim.MbiExport.Export(doc);
  56. Console.WriteLine("End Export");
  57. }
  58. catch (Exception e)
  59. {
  60. Console.WriteLine("导出失败");
  61. Console.WriteLine(e.StackTrace);
  62. }
  63. }
  64. public static void Check(Document doc)
  65. {
  66. try
  67. {
  68. Console.WriteLine("Start DataCheck");
  69. ServiceDataCheckTest.Check(doc);
  70. Console.WriteLine("End DataCheck");
  71. }
  72. catch (Exception e)
  73. {
  74. Console.WriteLine("导出失败");
  75. Console.WriteLine(e.StackTrace);
  76. }
  77. }
  78. }
  79. }