123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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 = null;
- string path = null;
- if (args.Length > 0)
- {
- command = args[0];
- }
- if (args.Length > 1)
- {
- path = args[1];
- }
- #if DEBUG
- if (string.IsNullOrWhiteSpace(command))
- {
- command = "DataExport";
- path = @"E:\导出测试\test.rvt";
- }
-
- #endif
- if (string.IsNullOrEmpty(command))
- {
- Console.WriteLine("命令参数错误");
- }
- Console.WriteLine(command);
- Console.WriteLine(path);
- 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);
- }
- }
- }
- }
|