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 path = @"C:\Users\SAGACLOUD\Desktop\数据检查\test.rvt";
            //path = @"C:\Users\SAGACLOUD\Desktop\数据检查\testR18.rvt";
            //path = @"C:\Users\SAGACLOUD\Desktop\数据检查\testR16.rvt";
            //path = @"D:\测试模型\OLD\机电模型2015.09.06\F5机电（改位置）\revit\5风管.rvt";
            string command = "Export";

            var app = RevitCoreContext.Instance.Application;
            var doc = app.OpenDocumentFile(path);
            //Export(doc);
            Check(doc);
            //Console.WriteLine("RevitVision:"+RevitVisionUtil.GetRevitVision(path));
            Console.ReadKey();
        }

        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);
            }
        }


    }
}
