| | |
| | | using Autodesk.Revit.DB;
|
| | | 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;
|
| | | using System.IO;
|
| | |
| | |
|
| | | 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;
|
| | |
|
| | |
| | |
|
| | | public static bool HideMode = false;
|
| | |
|
| | | public static bool IsOtherHidden = false;
|
| | |
|
| | | public static Dictionary<RevitType, string> DockablePanelDict => new Dictionary<RevitType, string>
|
| | | { |
| | | {
|
| | | {RevitType.RFT_Pump, "8AF8DA72-120F-44A0-81DD-5DD24EDAB919"},
|
| | | {RevitType.RFT_Valve, "1A2728E3-51FF-4084-B0B6-F6DAD26A56FB"},
|
| | | {RevitType.RFT_Pipe, "CB879681-B8E8-4FE2-BF57-4C86068D2C89"},
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | 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
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public static void Remove(this Dictionary<RevitType, ObservableCollection<ElementModel>> dict, string id)
|
| | | private static ElementModel CreateElementModel(Element elem, RevitType revitType)
|
| | | {
|
| | | return new ElementModel();
|
| | | }
|
| | |
|
| | | 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)
|
| | | {
|
| | | foreach (var pair in dict)
|
| | | if (pair.Value.Contains(id))
|
| | | {
|
| | | var models = pair.Value.Where(x=>x.Id == id);
|
| | | if (models != null)
|
| | | {
|
| | | foreach (var model in models)
|
| | | {
|
| | | pair.Value.Remove(model);
|
| | | }
|
| | | }
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|