From 43bd8ee779a4cca7483bdf73c176b9fb8ebed5e2 Mon Sep 17 00:00:00 2001 From: qin <a@163.com> Date: 星期二, 24 九月 2024 17:24:28 +0800 Subject: [PATCH] 水力计算 --- HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs | 159 +++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 117 insertions(+), 42 deletions(-) diff --git a/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs b/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs index b47c432..93813ad 100644 --- a/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs +++ b/HStation.RevitDev/RevitDataExport/Common/GlobalResource.cs @@ -2,10 +2,12 @@ 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; using HStation.RevitDev.RevitDataExport.Forms; +using HStation.RevitDev.RevitDataExport.Utility; using System; using System.Collections.Generic; using System.Collections.ObjectModel; @@ -31,7 +33,8 @@ public static string LastFilePath = string.Empty; - public static Dictionary<RevitType, ObservableCollection<ElementModel>> RevitModels = new Dictionary<RevitType, ObservableCollection<ElementModel>>(); + 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; @@ -44,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> { @@ -101,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; } } @@ -129,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 @@ -156,26 +207,14 @@ } } - public static ElementModel GetElementModel(string id) + public static bool Contains(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples, string id) { - foreach (var pair in RevitModels) - { - var elemModels = pair.Value; - var matchModels = elemModels.Where(x => x.Id == id); - if (matchModels == null || matchModels.Count() == 0) - { - continue; - } - return matchModels.First(); - } - return null; - } + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return false; } - public static bool Contains(this Dictionary<RevitType, ObservableCollection<ElementModel>> dict, string id) - { foreach (var pair in dict) { - if (pair.Value.Any(x => x.Id == id)) + if (pair.Value.Contains(id)) { return true; } @@ -183,71 +222,107 @@ return false; } - public static void Add(this Dictionary<RevitType, ObservableCollection<ElementModel>> 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 ObservableCollection<ElementModel>()); + dict.Add(type, new List<string>()); } - if (!dict[type].Any(x => x.Id == id)) + if (!dict[type].Contains(id)) { - dict[type].Add(new ElementModel - { - Id = id, - Name = elem.Name, - LinkIds = string.Empty - }); + dict[type].Add(id); } } } private static ElementModel CreateElementModel(Element elem, RevitType revitType) { - if (revitType == RevitType.RFT_Valve) - { - return new ValveModel(); - } return new ElementModel(); } - public static void Remove(this Dictionary<RevitType, ObservableCollection<ElementModel>> dict, string id) + public static void Remove(this List<Tuple<string, Dictionary<RevitType, List<string>>>> tuples, string id) { if (string.IsNullOrEmpty(id)) { return; } - if (dict.Contains(id)) + + var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2; + if (dict == null) { return; } + + foreach (var pair in dict) { - var models = dict.Values.Where(x => x.Any(y => y.Id == id))?.ToList(); - if (models != null && models.Count() == 0) + if (pair.Value.Contains(id)) { - for (int i = 0; i < models.Count(); i++) - { - models[i].RemoveAt(models[i].FindIndex(x=>x.Id == id)); - } + pair.Value.Remove(id); } } } - public static List<string> GetIds(this Dictionary<RevitType, ObservableCollection<ElementModel>> 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.Select(x => x.Id); - 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