8
1

2 Ревизии 8fea5ac8c4 ... 1dfc3ba785

Автор SHA1 Съобщение Дата
  xulisong 1dfc3ba785 Merge branch 'master' of http://39.106.8.246:3003/revit/RevitExport преди 5 години
  xulisong d92775ccf6 xls:去掉影响反射的revit扩展命令类 преди 5 години
променени са 3 файла, в които са добавени 63 реда и са изтрити 55 реда
  1. 3 3
      JBIM/ExportStart/Program.cs
  2. 25 17
      JBIM/RevitToJBim/MbiExport.cs
  3. 35 35
      JBIM/RevitToJBim/MbiExportCommand.cs

+ 3 - 3
JBIM/ExportStart/Program.cs

@@ -23,7 +23,7 @@ namespace ExportStart
         [STAThread]
         static void Main(string[] args)
         {
-            string path = @"C:\Users\SAGACLOUD\Desktop\数据检查\test.rvt";
+            string path = @"E:\导出测试\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";
@@ -31,8 +31,8 @@ namespace ExportStart
 
             var app = RevitCoreContext.Instance.Application;
             var doc = app.OpenDocumentFile(path);
-            //Export(doc);
-            Check(doc);
+            Export(doc);
+            //Check(doc);
             //Console.WriteLine("RevitVision:"+RevitVisionUtil.GetRevitVision(path));
             Console.ReadKey();
         }

+ 25 - 17
JBIM/RevitToJBim/MbiExport.cs

@@ -31,24 +31,32 @@ namespace RevitToJBim
         public static void Export(Document document)
         {
             //导出类
-            var wrappers = ExportDataBuilder.CreateExportData(document);
-            ExportInstance report = new ExportInstance(wrappers);
-            //解析类
-            JBimParseContext context = new JBimParseContext(ParseCore.GetUseParsers());
-            context.Parser.Parse(report);
+            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);
-            string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
-            string path = Path.Combine(@"D:\", $"{fileName}.json");
-            File.WriteAllText(path, result);
-            System.Diagnostics.Process.Start("notepad.exe", path);
+                //构建需要结果
+                var mbiDocument = MBIDocument.CreateDocument(document);
+                mbiDocument.AttachElements(context.GetResultDocument());
+                /*
+                 * 序列化的变化封装在这里,增加MBIDocument传输数据对象,
+                 * 增加一些和JBIM无关,又和当前业务逻辑相关的属性
+                 */
+                var result = BimJsonUtil.Serializer(mbiDocument);
+                string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
+                string path = Path.Combine(@"D:\", $"{fileName}.json");
+                File.WriteAllText(path, result);
+                System.Diagnostics.Process.Start("notepad.exe", path);
+            }
+            catch (Exception ex)
+            {
+
+                Console.WriteLine(ex.StackTrace.ToString());
+            }
         }
     }
 }

+ 35 - 35
JBIM/RevitToJBim/MbiExportCommand.cs

@@ -16,42 +16,42 @@ using Autodesk.Revit.UI;
 
 namespace RevitToJBim
 {
-    /// <summary>
-    /// 提取数据
-    /// </summary>
-    [Transaction(TransactionMode.Manual)]
-    [Regeneration(RegenerationOption.Manual)]
-    public class MbiExportCommand : IExternalCommand, IExternalCommandAvailability
-    {
+    ///// <summary>
+    ///// 提取数据
+    ///// </summary>
+    //[Transaction(TransactionMode.Manual)]
+    //[Regeneration(RegenerationOption.Manual)]
+    //public class MbiExportCommand : IExternalCommand, IExternalCommandAvailability
+    //{
 
-        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
-        {
-            try
-            {
-                var document = commandData.Application.ActiveUIDocument.Document;
-                MbiExport.Export(document);
-                TaskDialog dialog = new TaskDialog("导出");
-                dialog.MainInstruction = "导出成功";
-                dialog.Show();
-            }
-            catch (Exception e)
-            {
-                TaskDialog dialog = new TaskDialog("导出");
-                dialog.MainInstruction = e.Message + "\n\t" + e.StackTrace.ToString();
-                dialog.Show();
-                return Result.Cancelled;
-            }
-            return Result.Succeeded;
-        }
+    //    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
+    //    {
+    //        try
+    //        {
+    //            var document = commandData.Application.ActiveUIDocument.Document;
+    //            MbiExport.Export(document);
+    //            TaskDialog dialog = new TaskDialog("导出");
+    //            dialog.MainInstruction = "导出成功";
+    //            dialog.Show();
+    //        }
+    //        catch (Exception e)
+    //        {
+    //            TaskDialog dialog = new TaskDialog("导出");
+    //            dialog.MainInstruction = e.Message + "\n\t" + e.StackTrace.ToString();
+    //            dialog.Show();
+    //            return Result.Cancelled;
+    //        }
+    //        return Result.Succeeded;
+    //    }
 
 
-        /// <summary>
-        /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
-        /// when a document is open.
-        /// </summary>
-        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
-        {
-            return false;
-        }
-    }
+    //    /// <summary>
+    //    /// Onlys show the dialog when a document is open, as Dockable dialogs are only available
+    //    /// when a document is open.
+    //    /// </summary>
+    //    public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
+    //    {
+    //        return false;
+    //    }
+    //}
 }