From 9162a61818966f17e3aa2952c39d5484af1147d7 Mon Sep 17 00:00:00 2001
From: qin <a@163.com>
Date: 星期四, 22 八月 2024 16:02:27 +0800
Subject: [PATCH] 优化导出逻辑

---
 HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs b/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs
index 1b06581..4ab42ba 100644
--- a/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs
+++ b/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs
@@ -94,19 +94,32 @@
                     var structFile = tempDir + "\\struct.json";
                     var modelFile = tempDir + "\\model.rvt";
                     var settingFile = tempDir + "\\setting.json";
+                    var otherFile = tempDir + "\\struct_others.json";
                     if (File.Exists(structFile)) File.Delete(structFile);
+
                     if (File.Exists(modelFile)) File.Delete(modelFile);
                     if (!File.Exists(settingFile)) File.Create(settingFile).Close();
+                    if (!File.Exists(otherFile)) File.Create(otherFile).Close();
                     File.Copy(_doc.PathName, modelFile);
                     File.Copy(GlobalResource.ExportFilePath, structFile);
+
+                    var notContains = new List<string>() { "绠¢亾闄勪欢", "绠¢亾", "绠′欢 ", "绠¢亾闄勪欢", "绠¢亾绯荤粺" };
+                    var c3 = new Autodesk.Revit.DB.FilteredElementCollector(_doc).WhereElementIsNotElementType();//.WhereElementIsElementType();
+                    var c4 = new Autodesk.Revit.DB.FilteredElementCollector(_doc).WhereElementIsElementType();
+
+                    c3.Concat(c4);
+                    var r = c3.Where(c => c.Category != null && !notContains.Any(c.Category.Name.Contains)).Select(c => new { ID = c.Id.ToString(), Name = c.Name, CategoryName = c.Category.Name, CategoryID = c.Category.Id.ToString() }).Distinct().ToList();
+                    var t = JsonHelper.ToJson(r);
+                    File.WriteAllText(otherFile, t);
 
                     var setting = new SettingsViewModel() { Version = "1" };
                     File.WriteAllText(settingFile, JsonHelper.ToJson(setting));
 
-                    var files = new string[] { structFile, modelFile, settingFile };
+                    var files = new string[] { structFile, modelFile, settingFile, otherFile };
                     ZipFiles(files, zipFilePath);
 
                     File.Delete(structFile);
+                    File.Delete(otherFile);
                     File.Delete(modelFile);
                     File.Delete(settingFile);
                     return true;
@@ -116,9 +129,8 @@
                     err = JsonHelper.ToJson(ex);
                     return false;
                 }
-
             }
-            return true;
+            else return false;
 
         }
 

--
Gitblit v1.9.3