Program.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. if (File.Exists(path)&&Enum.TryParse(command, out CommandType commandType))
  27. {
  28. var app = RevitCoreContext.Instance.Application;
  29. var doc = app.OpenDocumentFile(path);
  30. switch (commandType)
  31. {
  32. case CommandType.DataCheck:
  33. Check(doc);
  34. break;
  35. case CommandType.DataExport:
  36. Export(doc);
  37. break;
  38. }
  39. RevitCoreContext.Instance.Stop();
  40. }
  41. }
  42. enum CommandType
  43. {
  44. None = 0,
  45. DataCheck,
  46. DataExport
  47. }
  48. public static void Export(Document doc)
  49. {
  50. try
  51. {
  52. Console.WriteLine("Start Export");
  53. RevitToJBim.MbiExport.Export(doc);
  54. Console.WriteLine("End Export");
  55. }
  56. catch (Exception e)
  57. {
  58. Console.WriteLine("导出失败");
  59. Console.WriteLine(e.StackTrace);
  60. }
  61. }
  62. public static void Check(Document doc)
  63. {
  64. try
  65. {
  66. Console.WriteLine("Start DataCheck");
  67. ServiceDataCheckTest.Check(doc);
  68. Console.WriteLine("End DataCheck");
  69. }
  70. catch (Exception e)
  71. {
  72. Console.WriteLine("导出失败");
  73. Console.WriteLine(e.StackTrace);
  74. }
  75. }
  76. }
  77. }