| | |
| | | using Autodesk.Revit.DB; |
| | | using HStation.RevitDev.Model.ModelEnum; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Reflection; |
| | | |
| | | namespace HStation.RevitDev.RevitDataExport.Common |
| | | { |
| | | public static class GlobalResource |
| | | { |
| | | public static readonly string PluginName = "泵系统分析"; |
| | | |
| | | public static readonly string PanelName = "族库"; |
| | | |
| | | public static AddInId CurrentAddinId = null; |
| | | |
| | | public static string UpdaterGuid = "345C723B-2244-46EE-B976-360FC14A543E"; |
| | | |
| | | public static List<string> ElementIds = new List<string>(); |
| | | |
| | | public static string LastFilePath = string.Empty; |
| | | |
| | | public static Dictionary<RevitType, List<string>> RevitModels = new Dictionary<RevitType, List<string>>(); |
| | | |
| | | public static RevitType RevitFamilyType = RevitType.RFT_Unknown; |
| | | |
| | | public static int ThumbnailSize = 150; |
| | | |
| | | public static string CurrentRevitVersion = string.Empty; |
| | | |
| | | public static bool InstancePlacing = false; |
| | | |
| | | public static bool PipePlacing = 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"}, |
| | | |
| | | {RevitType.RFT_FourJoint, "AAB55EEE-8450-4848-9C89-0322BBE94F5A"}, |
| | | {RevitType.RFT_Elbow, "C357EC81-09FF-41C5-8E32-FE71E30EA394"}, |
| | | {RevitType.RFT_Blocker, "0250FA8F-56C3-4355-817D-60B515CAD90E"}, |
| | | {RevitType.RFT_FireHydrant, "34E2EAD1-3D49-46C9-9942-451DD0192229"}, |
| | | {RevitType.RFT_HeatExchanger, "056EAACD-ED75-4854-8F3C-A4A43007BF31"}, |
| | | {RevitType.RFT_Reducing, "51F22122-04D5-4C28-9E68-1ADED0EABD04"}, |
| | | |
| | | {RevitType.RFT_Shower, "D4AA8261-406E-44FF-A1EE-531153FA9709"}, |
| | | {RevitType.RFT_ThreeJoint, "1BAA114A-E355-402C-B91D-569882D12987"}, |
| | | {RevitType.RFT_WaterBox, "44951F67-0C2F-4B02-B988-8B5F06295A18"}, |
| | | {RevitType.RFT_WaterMeter, "28354DCD-C11F-4EE8-89F8-72B9A93FD9E6"}, |
| | | {RevitType.RFT_WaterPool, "2DFB190E-1FD9-4CC6-8F85-AD3B19745ACF"}, |
| | | }; |
| | | |
| | | public static string BinDirectory |
| | | { |
| | | get |
| | | { |
| | | string result = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public static string DataDirectory |
| | | { |
| | | get |
| | | { |
| | | string result = Path.Combine(Path.GetDirectoryName(BinDirectory), "Data"); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public static string ExportFilePath |
| | | { |
| | | get |
| | | { |
| | | string result = Path.Combine(DataDirectory, "Export", "export.json"); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public static string ConfigFilePath |
| | | { |
| | | get |
| | | { |
| | | string result = Path.Combine(DataDirectory, "Config", "config.json"); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public static string FamilysDirectory |
| | | { |
| | | get |
| | | { |
| | | string result = Path.Combine(DataDirectory, "Familys"); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | public static string ImageDirectory |
| | | { |
| | | get |
| | | { |
| | | string result = Path.Combine(DataDirectory, "Image"); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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;
|
| | | using System.Linq;
|
| | | using System.Reflection;
|
| | |
|
| | | namespace HStation.RevitDev.RevitDataExport.Common
|
| | | {
|
| | | public static class GlobalResource
|
| | | {
|
| | | public static readonly string PluginName = "泵系统分析";
|
| | |
|
| | | public static readonly string PanelName = "族库";
|
| | |
|
| | | public static Document CurrentDocument = null;
|
| | |
|
| | | public static UIDocument CurrentUIDocument = null;
|
| | |
|
| | | public static AddInId CurrentAddinId = null;
|
| | |
|
| | | public static string InstancePaneGuid = "A64C3186-4905-4CEC-AB1D-41B39CEA4352";
|
| | |
|
| | | public static string LastFilePath = string.Empty;
|
| | |
|
| | | 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 Wpf_InstancePanel InstancePanel = null;
|
| | |
|
| | | public static Wpf_FamilyPanel FamilyPanel = null;
|
| | |
|
| | | public static int ThumbnailSize = 150;
|
| | |
|
| | | 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>
|
| | | {
|
| | | {RevitType.RFT_Pump, "8AF8DA72-120F-44A0-81DD-5DD24EDAB919"},
|
| | | {RevitType.RFT_Valve, "1A2728E3-51FF-4084-B0B6-F6DAD26A56FB"},
|
| | | {RevitType.RFT_Pipe, "CB879681-B8E8-4FE2-BF57-4C86068D2C89"},
|
| | |
|
| | | {RevitType.RFT_FourJoint, "AAB55EEE-8450-4848-9C89-0322BBE94F5A"},
|
| | | {RevitType.RFT_Elbow, "C357EC81-09FF-41C5-8E32-FE71E30EA394"},
|
| | | {RevitType.RFT_Blocker, "0250FA8F-56C3-4355-817D-60B515CAD90E"},
|
| | | {RevitType.RFT_FireHydrant, "34E2EAD1-3D49-46C9-9942-451DD0192229"},
|
| | | {RevitType.RFT_HeatExchanger, "056EAACD-ED75-4854-8F3C-A4A43007BF31"},
|
| | | {RevitType.RFT_Converter, "51F22122-04D5-4C28-9E68-1ADED0EABD04"},
|
| | |
|
| | | {RevitType.RFT_Shower, "D4AA8261-406E-44FF-A1EE-531153FA9709"},
|
| | | {RevitType.RFT_ThreeJoint, "1BAA114A-E355-402C-B91D-569882D12987"},
|
| | | {RevitType.RFT_WaterBox, "44951F67-0C2F-4B02-B988-8B5F06295A18"},
|
| | | {RevitType.RFT_WaterMeter, "28354DCD-C11F-4EE8-89F8-72B9A93FD9E6"},
|
| | | {RevitType.RFT_WaterPool, "2DFB190E-1FD9-4CC6-8F85-AD3B19745ACF"},
|
| | | };
|
| | |
|
| | | public static string BinDirectory
|
| | | {
|
| | | get
|
| | | {
|
| | | string result = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
| | | return result;
|
| | | }
|
| | | }
|
| | |
|
| | | public static string DataDirectory
|
| | | {
|
| | | get
|
| | | {
|
| | | string result = Path.Combine(Path.GetDirectoryName(BinDirectory), "Data");
|
| | | return result;
|
| | | }
|
| | | }
|
| | |
|
| | | public static string ExportFilePath
|
| | | {
|
| | | get
|
| | | {
|
| | | string result = Path.Combine(DataDirectory, "Export", "export.json");
|
| | | return result;
|
| | | }
|
| | | }
|
| | |
|
| | | public static string RecordFilePath
|
| | | {
|
| | | get
|
| | | {
|
| | | string result = Path.Combine(DataDirectory, "Config", "record.json");
|
| | | return result;
|
| | | }
|
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | | }
|
| | |
|
| | | public static string FamilysDirectory
|
| | | {
|
| | | get
|
| | | {
|
| | | string result = Path.Combine(DataDirectory, "Familys");
|
| | | return result;
|
| | | }
|
| | | }
|
| | |
|
| | | public static string ImageDirectory
|
| | | {
|
| | | get
|
| | | {
|
| | | string result = Path.Combine(DataDirectory, "Image");
|
| | | 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
|
| | | {
|
| | | if (configModel != null)
|
| | | {
|
| | | return configModel;
|
| | | }
|
| | | if (!File.Exists(ConfigFilePath))
|
| | | {
|
| | | return new ConfigModel();
|
| | | }
|
| | | var strConfig = File.ReadAllText(ConfigFilePath);
|
| | | if (string.IsNullOrEmpty(strConfig))
|
| | | {
|
| | | return new ConfigModel();
|
| | | }
|
| | | var ret = Newtonsoft.Json.JsonConvert.DeserializeObject<ConfigModel>(strConfig);
|
| | | if (ret == null)
|
| | | {
|
| | | return new ConfigModel();
|
| | | }
|
| | | configModel = ret;
|
| | | return configModel;
|
| | | }
|
| | | }
|
| | |
|
| | | 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))
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | 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 (!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>());
|
| | | }
|
| | | if (!dict[type].Contains(id))
|
| | | {
|
| | | dict[type].Add(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;
|
| | | }
|
| | |
|
| | | var dict = tuples.Find(x => x.Item1 == CurrentDocument.Title)?.Item2;
|
| | | if (dict == null) { return; }
|
| | |
|
| | | foreach (var pair in dict)
|
| | | {
|
| | | if (pair.Value.Contains(id))
|
| | | {
|
| | | pair.Value.Remove(id);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | 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)
|
| | | {
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|