/*------------------------------------------------------------------------- * 功能描述:TestExport * 作者:xulisong * 创建时间: 2019/6/18 15:43:54 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.IO; using Autodesk.Revit.DB; using MBIRevitBase.Services; using MBIRevitBase.Tools; using RevitExport.Export; using RevitToJBim.ComponentParse; using RevitToJBim.JsonConverter; using RevitToJBim.MBI; namespace RevitToJBim { public class MbiExport { public static void Export(Document document) { //导出类 try { var wrappers = ExportDataBuilder.CreateExportData(document); ExportInstance report = new ExportInstance(wrappers); //解析类 JBimParseContext context = new JBimParseContext(ParseCore.GetUseParsers()); context.Parser.Parse(report); //构建需要结果 var mbiDocument = MBIDocument.CreateDocument(document); mbiDocument.AttachElements(context.GetResultDocument()); /* * 序列化的变化封装在这里,增加MBIDocument传输数据对象, * 增加一些和JBIM无关,又和当前业务逻辑相关的属性 */ var result = BimJsonUtil.Serializer(mbiDocument); var resultResponse = UploadService.UploadExportFile(result); //string fileName = DateTime.Now.ToString("yyyyMMddHHmmss"); //string path = Path.Combine(@"D:\", $"{fileName}.json"); //File.WriteAllText(path, resultResponse.ToString()); //System.Diagnostics.Process.Start("notepad.exe", path); } catch (Exception ex) { Console.WriteLine(ex.StackTrace.ToString()); } } } }