From e358beb08f5be49703009b64f058ecfbcfeefbd9 Mon Sep 17 00:00:00 2001
From: qin <a@163.com>
Date: 星期六, 28 九月 2024 14:27:52 +0800
Subject: [PATCH] 测试standard2.1

---
 HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs |   78 +++++++++++++++++++++++++++++++--------
 1 files changed, 62 insertions(+), 16 deletions(-)

diff --git a/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs b/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs
index 4ab42ba..0b43d1c 100644
--- a/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs
+++ b/HStation.RevitDev/RevitDataExport/Utility/CacheUtil.cs
@@ -8,6 +8,7 @@
 using System.IO;
 using System.Linq;
 using System.Windows.Forms;
+using Autodesk.Revit.UI;
 
 namespace HStation.RevitDev.RevitDataExport.Utility
 {
@@ -84,17 +85,17 @@
             err = "";
             if (dialog.ShowDialog() == DialogResult.OK)
             {
+                var tempDir = Path.Combine(Path.GetDirectoryName(GlobalResource.BinDirectory), "temp"); //"d:\\temp";
+                if (!Directory.Exists(tempDir))
+                    Directory.CreateDirectory(tempDir);
+                var structFile = tempDir + "\\struct.json";
+                var modelFile = tempDir + "\\model.rvt";
+                var settingFile = tempDir + "\\setting.json";
+                var otherFile = tempDir + "\\struct_others.json";
+
                 try
                 {
                     var zipFilePath = dialog.SelectedPath + "\\model.ywrvt";
-
-                    var tempDir = "d:\\temp";
-                    if (!Directory.Exists(tempDir))
-                        Directory.CreateDirectory(tempDir);
-                    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);
@@ -122,10 +123,16 @@
                     File.Delete(otherFile);
                     File.Delete(modelFile);
                     File.Delete(settingFile);
+                    File.Delete(otherFile);
                     return true;
                 }
                 catch (Exception ex)
                 {
+                    File.Delete(structFile);
+                    File.Delete(otherFile);
+                    File.Delete(modelFile);
+                    File.Delete(settingFile);
+                    File.Delete(otherFile);
                     err = JsonHelper.ToJson(ex);
                     return false;
                 }
@@ -176,19 +183,58 @@
             {
                 return;
             }
-            GlobalResource.HideMode = !GlobalResource.HideMode;
-            using (Transaction trans = new Transaction(document, "hide elements"))
+            try
             {
-                trans.Start();
-                if (GlobalResource.HideMode)
+                GlobalResource.HideMode = !GlobalResource.HideMode;
+                using (Transaction trans = new Transaction(document, "hide elements"))
                 {
-                    document.ActiveView.HideElements(ids);
+                    trans.Start();
+                    if (GlobalResource.HideMode)
+                    {
+                        document.ActiveView.HideElements(ids);
+                    }
+                    else
+                    {
+                        document.ActiveView.UnhideElements(ids);
+                    }
+                    trans.Commit();
                 }
-                else
+            }
+            catch (Exception ex)
+            {
+                TaskDialog.Show("閿欒", "鏄鹃殣澶辫触锛屽彲鑳藉瓨鍦ㄤ笉鑳借缃殣钘忕殑鏋勪欢锛�");
+            }
+        }
+
+        public static void HideOrShowOtherModels(Document document)
+        {
+            if (document == null) { return; }
+
+            var ids = GlobalResource.RevitModels.GetOtherIds()?.Select(x => new ElementId(int.Parse(x))).ToList();
+            if (ids.Count == 0)
+            {
+                return;
+            }
+            try
+            {
+                GlobalResource.IsOtherHidden = !GlobalResource.IsOtherHidden;
+                using (Transaction trans = new Transaction(document, "hide other elements"))
                 {
-                    document.ActiveView.UnhideElements(ids);
+                    trans.Start();
+                    if (GlobalResource.IsOtherHidden)
+                    {
+                        document.ActiveView.HideElements(ids);
+                    }
+                    else
+                    {
+                        document.ActiveView.UnhideElements(ids);
+                    }
+                    trans.Commit();
                 }
-                trans.Commit();
+            }
+            catch (Exception ex)
+            {
+                TaskDialog.Show("閿欒", "鏄鹃殣澶辫触锛屽彲鑳藉瓨鍦ㄤ笉鑳借缃殣钘忕殑鏋勪欢锛�");
             }
         }
     }

--
Gitblit v1.9.3