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 ServiceRevitLib; //using RevitToJBim.Common; namespace ExportStart { class Program { static Program() { RevitCoreContext.Instance.Run(); } [STAThread] static void Main(string[] args) { string command = args[0]; string path = args[1]; //string command = "DataExport"; //string path = @"E:\导出测试\test.rvt"; if (File.Exists(path)&&Enum.TryParse(command, out CommandType commandType)) { var app = RevitCoreContext.Instance.Application; var doc = app.OpenDocumentFile(path); switch (commandType) { case CommandType.DataCheck: Check(doc); break; case CommandType.DataExport: Export(doc); break; } RevitCoreContext.Instance.Stop(); } } enum CommandType { None = 0, DataCheck, DataExport } public static void Export(Document doc) { try { Console.WriteLine("Start Export"); RevitToJBim.MbiExport.Export(doc); Console.WriteLine("End Export"); } catch (Exception e) { Console.WriteLine("导出失败"); Console.WriteLine(e.StackTrace); } } public static void Check(Document doc) { try { Console.WriteLine("Start DataCheck"); ServiceDataCheckTest.Check(doc); Console.WriteLine("End DataCheck"); } catch (Exception e) { Console.WriteLine("导出失败"); Console.WriteLine(e.StackTrace); } } } }