Program.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Autodesk.Revit.DB;
  2. using ServiceRevitLib;
  3. using System;
  4. using System.IO;
  5. //using RevitToJBim.Common;
  6. namespace ExportStart
  7. {
  8. class Program
  9. {
  10. static Program()
  11. {
  12. RevitCoreContext.Instance.Run();
  13. }
  14. [STAThread]
  15. static void Main(string[] args)
  16. {
  17. //RevitCoreContext.Instance.Run();
  18. string path = @"E:\导出测试\testR17.rvt";
  19. try
  20. {
  21. path = args[0];
  22. string command = "Export";
  23. var app = RevitCoreContext.Instance.Application;
  24. var doc = app.OpenDocumentFile(path);
  25. Export(doc);
  26. Check(doc);
  27. //File.AppendAllLines(@"D:\RevitDll.txt",RevitCoreContext.NeedAssemblys );
  28. RevitCoreContext.Instance.Stop();
  29. }
  30. catch (Exception e)
  31. {
  32. Console.WriteLine(e);
  33. }
  34. }
  35. public static void Export(Document doc)
  36. {
  37. try
  38. {
  39. Console.WriteLine("Start Export");
  40. RevitToJBim.MbiExport.Export(doc);
  41. Console.WriteLine("End Export");
  42. }
  43. catch (Exception e)
  44. {
  45. Console.WriteLine("导出失败");
  46. throw;
  47. Console.WriteLine(e.StackTrace);
  48. }
  49. }
  50. public static void Check(Document doc)
  51. {
  52. try
  53. {
  54. Console.WriteLine("Start DataCheck");
  55. ServiceDataCheckTest.Check(doc);
  56. Console.WriteLine("End DataCheck");
  57. }
  58. catch (Exception e)
  59. {
  60. Console.WriteLine("导出失败");
  61. throw;
  62. Console.WriteLine(e.StackTrace);
  63. }
  64. }
  65. }
  66. }