|
@@ -2,6 +2,8 @@
|
|
|
using ServiceRevitLib;
|
|
|
using System;
|
|
|
using System.IO;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using SAGA.DotNetUtils.Extend;
|
|
|
|
|
|
//using RevitToJBim.Common;
|
|
|
|
|
@@ -17,6 +19,7 @@ namespace ExportStart
|
|
|
static void Main(string[] args)
|
|
|
{
|
|
|
string command = null;
|
|
|
+ string param = null;
|
|
|
string path = null;
|
|
|
if (args.Length > 0)
|
|
|
{
|
|
@@ -24,15 +27,26 @@ namespace ExportStart
|
|
|
}
|
|
|
if (args.Length > 1)
|
|
|
{
|
|
|
- path = args[1];
|
|
|
+ param = args[1];
|
|
|
+ }
|
|
|
+ if (args.Length > 2)
|
|
|
+ {
|
|
|
+ path = args[2];
|
|
|
}
|
|
|
#if DEBUG
|
|
|
if (string.IsNullOrWhiteSpace(command))
|
|
|
{
|
|
|
command = "DataExport";
|
|
|
- path = @"E:\导出测试\test.rvt";
|
|
|
- }
|
|
|
+ path = @"E:\导出测试\testR17.rvt";
|
|
|
+ path = @"E:\导出测试\TestEmptyR17.rvt";
|
|
|
+ JObject jObject=new JObject();
|
|
|
+ jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");
|
|
|
+ param = jObject.ToString();
|
|
|
|
|
|
+ //path= @"E:\导出测试\延庆园-B1.rvt";
|
|
|
+ //path = @"E:\导出测试\testR18.rvt";
|
|
|
+ //path = @"E:\导出测试\testR16.rvt";
|
|
|
+ }
|
|
|
#endif
|
|
|
if (string.IsNullOrEmpty(command))
|
|
|
{
|
|
@@ -44,17 +58,53 @@ namespace ExportStart
|
|
|
{
|
|
|
var app = RevitCoreContext.Instance.Application;
|
|
|
var doc = app.OpenDocumentFile(path);
|
|
|
+ string result = null;
|
|
|
switch (commandType)
|
|
|
{
|
|
|
case CommandType.DataCheck:
|
|
|
- Check(doc);
|
|
|
+ result=Check(doc,param);
|
|
|
break;
|
|
|
case CommandType.DataExport:
|
|
|
- Export(doc);
|
|
|
+ result=Export(doc,param);
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
+ SaveResult(param, result);
|
|
|
RevitCoreContext.Instance.Stop();
|
|
|
}
|
|
|
+ Console.WriteLine("ExportStart End");
|
|
|
+ }
|
|
|
+ /// <summary>
|
|
|
+ /// 保存检查或导出的结果
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="param"></param>
|
|
|
+ /// <param name="result"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private static void SaveResult(string param, string result)
|
|
|
+ {
|
|
|
+ Console.WriteLine(param);
|
|
|
+ File.AppendAllText(@"D:\log.txt", param);
|
|
|
+ try
|
|
|
+ {
|
|
|
+
|
|
|
+ JObject jObject = JObject.Parse(param);
|
|
|
+ string key = "ResultFileName";
|
|
|
+ string path = jObject[key].ToString();
|
|
|
+ File.AppendAllText(@"D:\log.txt", path);
|
|
|
+ if (path.IsNotNullEmpty())
|
|
|
+ {
|
|
|
+ Console.WriteLine(path);
|
|
|
+ var dir = Directory.GetParent(path);
|
|
|
+ if(!dir.Exists)
|
|
|
+ dir.Create();
|
|
|
+ File.AppendAllText(@"D:\log.txt", result);
|
|
|
+ File.AppendAllText(path, result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ Console.WriteLine(e);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
enum CommandType
|
|
@@ -65,12 +115,13 @@ namespace ExportStart
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void Export(Document doc)
|
|
|
+ public static string Export(Document doc,string param)
|
|
|
{
|
|
|
+ string result = null;
|
|
|
try
|
|
|
{
|
|
|
Console.WriteLine("Start Export");
|
|
|
- RevitToJBim.MbiExport.Export(doc);
|
|
|
+ result=RevitToJBim.MbiExport.Export(doc,param);
|
|
|
|
|
|
Console.WriteLine("End Export");
|
|
|
}
|
|
@@ -79,15 +130,18 @@ namespace ExportStart
|
|
|
Console.WriteLine("导出失败");
|
|
|
Console.WriteLine(e.StackTrace);
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static void Check(Document doc)
|
|
|
+ public static string Check(Document doc,string param)
|
|
|
{
|
|
|
+ string result = null;
|
|
|
try
|
|
|
{
|
|
|
Console.WriteLine("Start DataCheck");
|
|
|
- ServiceDataCheckTest.Check(doc);
|
|
|
+ result=ServiceDataCheckTest.Check(doc);
|
|
|
|
|
|
Console.WriteLine("End DataCheck");
|
|
|
}
|
|
@@ -96,6 +150,8 @@ namespace ExportStart
|
|
|
Console.WriteLine("导出失败");
|
|
|
Console.WriteLine(e.StackTrace);
|
|
|
}
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|