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/Common/GlobalResource.cs | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 110 insertions(+), 8 deletions(-) diff --git a/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs b/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs index 999774b..93813ad 100644 --- a/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs +++ b/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs @@ -2,6 +2,7 @@ using Autodesk.Revit.UI; using DevExpress.Data.Extensions; using DevExpress.XtraPrinting.Native; +using Glodon.Revit.Utility; using HStation.RevitDev.Model.ModelEnum; using HStation.RevitDev.RevitDataExport.Entity; using HStation.RevitDev.RevitDataExport.Entity.ElementModels; @@ -32,7 +33,8 @@ public static string LastFilePath = string.Empty; - public static Dictionary<RevitType, List<string>> RevitModels = new Dictionary<RevitType, List<string>>(); + public static List<Tuple<string, Dictionary<RevitType, List<string>>>> RevitModels = + new List<Tuple<string, Dictionary<RevitType, List<string>>>>(); public static RevitType PlacingType = RevitType.RFT_Unknown; @@ -45,6 +47,8 @@ public static string CurrentRevitVersion = string.Empty; public static bool HideMode = false; + + public static bool IsOtherHidden = false; public static Dictionary<RevitType, string> DockablePanelDict => new Dictionary<RevitType, string> { @@ -102,11 +106,29 @@ } } + public static string ParamsFilePath + { + get + { + string result = Path.Combine(DataDirectory, "Config", "familyparams.json"); + return result; + } + } + public static string ConfigFilePath { get { string result = Path.Combine(DataDirectory, "Config", "config.json"); + return result; + } + } + + public static string SettingFilePath + { + get + { + string result = Path.Combine(DataDirectory, "Config", "setting.json"); return result; } } @@ -130,6 +152,34 @@ } private static ConfigModel configModel = null; + private static ConfigSettingModel configSettingModel = null; + + public static ConfigSettingModel ConfigSettingModel + { + get + { + if (configSettingModel != null) + { + return configSettingModel; + } + if (!File.Exists(ConfigFilePath)) + { + return new ConfigSettingModel() { SystemType= ConfigHelper.SystemType.All }; + } + var strConfig = File.ReadAllText(SettingFilePath); + if (string.IsNullOrEmpty(strConfig)) + { + return new ConfigSettingModel() { SystemType = ConfigHelper.SystemType.All }; + } + var ret = Newtonsoft.Json.JsonConvert.DeserializeObject<ConfigSettingModel>(strConfig); + if (ret == null) + { + return new ConfigSettingModel() { SystemType = ConfigHelper.SystemType.All }; + } + configSettingModel = ret; + return configSettingModel; + } + } public static ConfigModel ConfigModel { get @@ -157,8 +207,11 @@ } } - public static bool Contains(this Dictionary<RevitType, List<string>> dict, string id) + public static bool Contains(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples, string id) { + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return false; } + foreach (var pair in dict) { if (pair.Value.Contains(id)) @@ -169,16 +222,29 @@ return false; } - public static void Add(this Dictionary<RevitType, List<string>> dict, Element elem, RevitType type = RevitType.RFT_Others) + public static void Add(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples, Element elem, RevitType type = RevitType.RFT_Others) { if (elem == null) { return; } + //var ps = elem.GetParameterByProName("鏄惁鑷畾涔�"); + //if ((type != RevitType.RFT_Others && type != RevitType.RFT_Pipe) && (ps == null || !ps.AsString().Equals("鏄�"))) + //{ + // return; + //} + var id = elem.Id.IntegerValue.ToString(); - if (!dict.Contains(id)) + if (!tuples.Contains(id)) { + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) + { + dict = new Dictionary<RevitType, List<string>>(); + tuples.Add(new Tuple<string, Dictionary<RevitType, List<string>>>(elem.Document.Title, dict)); + } + if (!dict.ContainsKey(type)) { dict.Add(type, new List<string>()); @@ -195,12 +261,16 @@ return new ElementModel(); } - public static void Remove(this Dictionary<RevitType, List<string>> dict, string id) + public static void Remove(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples, string id) { if (string.IsNullOrEmpty(id)) { return; } + + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return; } + foreach (var pair in dict) { if (pair.Value.Contains(id)) @@ -210,17 +280,49 @@ } } - public static List<string> GetIds(this Dictionary<RevitType, List<string>> dict) + public static List<string> GetIds(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples) { var ret = new List<string>(); + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return ret; } + foreach (var pair in dict) { - var subList = pair.Value; - ret.AddRange(subList); + if (pair.Key != RevitType.RFT_Others) + { + var subList = pair.Value; + ret.AddRange(subList); + } } return ret; } + + public static List<string> GetOtherIds(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples) + { + var ret = new List<string>(); + + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return ret; } + + foreach (var pair in dict) + { + if (pair.Key == RevitType.RFT_Others) + { + var subList = pair.Value; + ret.AddRange(subList); + } + } + + return ret; + } + + public static bool ContainsKey(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples, RevitType type) + { + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return false; } + return dict.ContainsKey(type); + } } } -- Gitblit v1.9.3