From 31cca463443f7bc8b6b1bd02889844b864d93e11 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期四, 07 十一月 2024 00:38:50 +0800 Subject: [PATCH] Revit解析修改 --- Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs | 291 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 228 insertions(+), 63 deletions(-) diff --git a/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs b/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs index 6651f73..04f52ce 100644 --- a/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs +++ b/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs @@ -33,6 +33,10 @@ {//淇鎹㈢儹鍣� result = false; } + if (!CorrectCompressor(rhs, ref msgList)) + {//淇绌哄帇鏈� + result = false; + } if (!CorrectCode(rhs, ref msgList)) {//淇缂栫爜 result = false; @@ -88,6 +92,14 @@ {//鍥涢�� rhs.Fourlinks = new List<Model.RevitFourlink>(); } + if (rhs.Nozzles == null) + {//鍠峰ご + rhs.Nozzles = new List<Model.RevitNozzle>(); + } + if (rhs.Hydrants == null) + {//娑堢伀鏍� + rhs.Hydrants = new List<Model.RevitHydrant>(); + } if (rhs.Meters == null) {//姘磋〃 rhs.Meters = new List<RevitMeter>(); @@ -100,14 +112,6 @@ {//鍘嬪姏琛� rhs.Pressmeters = new List<Model.RevitPressmeter>(); } - if (rhs.Nozzles == null) - {//鍠峰ご - rhs.Nozzles = new List<Model.RevitNozzle>(); - } - if (rhs.Hydrants == null) - {//娑堢伀鏍� - rhs.Hydrants = new List<Model.RevitHydrant>(); - } if (rhs.Pipes == null) {//绠¢亾 @@ -117,10 +121,6 @@ {//杩囨浮浠� rhs.Translations = new List<Model.RevitTranslation>(); } - if (rhs.Exchangers == null) - {//鎹㈢儹鍣� - rhs.Exchangers = new List<RevitExchanger>(); - } if (rhs.Pumps == null) {//姘存车 rhs.Pumps = new List<Model.RevitPump>(); @@ -128,6 +128,14 @@ if (rhs.Valves == null) {//闃�闂� rhs.Valves = new List<Model.RevitValve>(); + } + if (rhs.Exchangers == null) + {//鎹㈢儹鍣� + rhs.Exchangers = new List<RevitExchanger>(); + } + if (rhs.Compressors == null) + {//绌哄帇鏈� + rhs.Compressors = new List<RevitCompressor>(); } return true; } @@ -338,19 +346,6 @@ } } } - if (rhs.Exchangers != null && rhs.Exchangers.Count > 0) - {//鎹㈢儹鍣� - var exchangerNameList = rhs.Exchangers.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); - foreach (var exchanger in rhs.Exchangers) - { - if (string.IsNullOrEmpty(exchanger.Name)) - { - var exchangerName = Yw.Untity.UniqueHelper.CreateFromFirst("鎹㈢儹鍣�", exchangerNameList); - exchanger.Name = exchangerName; - exchangerNameList.Add(exchangerName); - } - } - } if (rhs.Pumps != null && rhs.Pumps.Count > 0) {//姘存车 var pumpNameList = rhs.Pumps.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); @@ -374,6 +369,32 @@ var valveName = Yw.Untity.UniqueHelper.CreateFromFirst("闃�闂�", valveNameList); valve.Name = valveName; valveNameList.Add(valveName); + } + } + } + if (rhs.Exchangers != null && rhs.Exchangers.Count > 0) + {//鎹㈢儹鍣� + var exchangerNameList = rhs.Exchangers.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); + foreach (var exchanger in rhs.Exchangers) + { + if (string.IsNullOrEmpty(exchanger.Name)) + { + var exchangerName = Yw.Untity.UniqueHelper.CreateFromFirst("鎹㈢儹鍣�", exchangerNameList); + exchanger.Name = exchangerName; + exchangerNameList.Add(exchangerName); + } + } + } + if (rhs.Compressors != null && rhs.Compressors.Count > 0) + {//绌哄帇鏈� + var compressorNameList = rhs.Compressors.Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name).Distinct().ToList(); + foreach (var compressor in rhs.Compressors) + { + if (string.IsNullOrEmpty(compressor.Name)) + { + var compressorName = Yw.Untity.UniqueHelper.CreateFromFirst("绌哄帇鏈�", compressorNameList); + compressor.Name = compressorName; + compressorNameList.Add(compressorName); } } } @@ -414,7 +435,6 @@ { var decorator = new Model.RevitDecorator(); decorator.Id = blunthead.Id; - decorator.Code = blunthead.Code; decorator.Name = blunthead.Name; decorator.Category = RevitJsonCatalog.Blunthead; decorator.Decoration = null; @@ -441,24 +461,22 @@ } if (startConnectList.Count < 1) { - msgList.Add($"鎹㈢儹鍣╗{exchanger.Code}]涓婃父杩炴帴缁勪欢涓嶅瓨鍦�"); + msgList.Add($"鎹㈢儹鍣╗{exchanger.Id}]涓婃父杩炴帴缁勪欢涓嶅瓨鍦�"); result = false; continue; } var startJunction = new Model.RevitJunction(); - startJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); - startJunction.Code = startJunction.Id; + startJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); startJunction.Name = UniqueHelper.CreateFromFirst("杩炴帴鑺傜偣", allParterList.Select(x => x.Name).Distinct().ToList()); startJunction.Flags = null; startJunction.ModelType = null; startJunction.Description = "鎹㈢儹鍣ㄤ慨姝f椂锛岃嚜鍔ㄦ坊鍔�"; - startJunction.Quality = exchanger.StartQuality; startJunction.Position = startConnectList.GetCenterPosition(); - startJunction.Elev = exchanger.StartElev; + startJunction.Elev = exchanger.Elev; startJunction.Demand = null; startJunction.DemandPattern = null; rhs.Junctions.Add(startJunction); - exchanger.StartCode = startJunction.Code; + exchanger.StartCode = startJunction.Id; foreach (var startConnect in startConnectList) { var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id); @@ -491,24 +509,22 @@ } if (endConnectList.Count < 1) { - msgList.Add($"鎹㈢儹鍣╗{exchanger.Code}]涓嬫父杩炴帴缁勪欢涓嶅瓨鍦�"); + msgList.Add($"鎹㈢儹鍣╗{exchanger.Id}]涓嬫父杩炴帴缁勪欢涓嶅瓨鍦�"); result = false; continue; } var endJunction = new Model.RevitJunction(); - endJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); - endJunction.Code = endJunction.Id; + endJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); endJunction.Name = UniqueHelper.CreateFromFirst("杩炴帴鑺傜偣", allParterList.Select(x => x.Name).Distinct().ToList()); endJunction.Flags = null; endJunction.ModelType = null; endJunction.Description = "鎹㈢儹鍣ㄤ慨姝f椂锛岃嚜鍔ㄦ坊鍔�"; - endJunction.Quality = exchanger.EndQuality; endJunction.Position = endConnectList.GetCenterPosition(); - endJunction.Elev = exchanger.EndElev; + endJunction.Elev = exchanger.Elev; endJunction.Demand = null; endJunction.DemandPattern = null; rhs.Junctions.Add(endJunction); - exchanger.EndCode = endJunction.Code; + exchanger.EndCode = endJunction.Id; foreach (var endConnect in endConnectList) { var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id); @@ -530,7 +546,160 @@ } else { - msgList.Add($"鎹㈢儹鍣╗{exchanger.Code}]杩炴帴鍒楄〃涓虹┖"); + msgList.Add($"鎹㈢儹鍣╗{exchanger.Id}]杩炴帴鍒楄〃涓虹┖"); + result = false; + } + } + } + return result; + } + + //淇绌哄帇鏈� + private static bool CorrectCompressor(Model.RevitModel rhs, ref List<string> msgList) + { + if (rhs == null) + { + return false; + } + if (msgList == null) + { + msgList = new List<string>(); + } + var result = true; + if (rhs.Compressors != null && rhs.Compressors.Count > 0) + { + var allParterList = rhs.GetAllParters(); + foreach (var compressor in rhs.Compressors) + { + if (compressor.ConnectList != null && compressor.ConnectList.Count > 0) + { + #region 鍘婚櫎鏃犳晥杩炴帴鍜岄椃澶� + + foreach (var connect in compressor.ConnectList.ToList()) + { + var connectParter = allParterList.Find(x => x.Id == connect.Id); + if (connectParter == null) + { + compressor.ConnectList.Remove(connect); + } + else + { + if (connectParter is RevitBlunthead blunthead) + { + var decorator = new Model.RevitDecorator(); + decorator.Id = blunthead.Id; + decorator.Name = blunthead.Name; + decorator.Category = RevitJsonCatalog.Blunthead; + decorator.Decoration = null; + decorator.Description = blunthead.Description; + rhs.Decorators.Add(decorator); + rhs.Bluntheads.Remove(blunthead); + allParterList.Remove(connectParter); + } + } + } + + #endregion + + #region 寮�濮嬭繛鎺� + + var startConnectList = compressor.ConnectList.GetStartConnects(); + if (startConnectList.Count < 1) + { + var startConnect = compressor.ConnectList.GetStartConnect(); + if (startConnect != null) + { + startConnectList.Add(startConnect); + } + } + if (startConnectList.Count < 1) + { + msgList.Add($"绌哄帇鏈篬{compressor.Id}]涓婃父杩炴帴缁勪欢涓嶅瓨鍦�"); + result = false; + continue; + } + var startJunction = new Model.RevitJunction(); + startJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); + startJunction.Name = UniqueHelper.CreateFromFirst("杩炴帴鑺傜偣", allParterList.Select(x => x.Name).Distinct().ToList()); + startJunction.Flags = null; + startJunction.ModelType = null; + startJunction.Description = "绌哄帇鏈轰慨姝f椂锛岃嚜鍔ㄦ坊鍔�"; + startJunction.Position = startConnectList.GetCenterPosition(); + startJunction.Elev = compressor.Elev; + startJunction.Demand = null; + startJunction.DemandPattern = null; + rhs.Junctions.Add(startJunction); + compressor.StartCode = startJunction.Id; + foreach (var startConnect in startConnectList) + { + var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id); + if (startConnectParter is RevitLink revitLink) + { + if (revitLink.StartCode == compressor.Id) + { + revitLink.StartCode = startJunction.Id; + } + else if (revitLink.EndCode == compressor.Id) + { + revitLink.EndCode = startJunction.Id; + } + } + } + allParterList.Add(startJunction); + + #endregion + + #region 缁撴潫杩炴帴 + + var endConnectList = compressor.ConnectList.GetEndConnects(); + if (endConnectList.Count < 1) + { + var endConnect = compressor.ConnectList.GetEndConnect(); + if (endConnect != null) + { + endConnectList.Add(endConnect); + } + } + if (endConnectList.Count < 1) + { + msgList.Add($"绌哄帇鏈篬{compressor.Id}]涓嬫父杩炴帴缁勪欢涓嶅瓨鍦�"); + result = false; + continue; + } + var endJunction = new Model.RevitJunction(); + endJunction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); + endJunction.Name = UniqueHelper.CreateFromFirst("杩炴帴鑺傜偣", allParterList.Select(x => x.Name).Distinct().ToList()); + endJunction.Flags = null; + endJunction.ModelType = null; + endJunction.Description = "绌哄帇鏈轰慨姝f椂锛岃嚜鍔ㄦ坊鍔�"; + endJunction.Position = endConnectList.GetCenterPosition(); + endJunction.Elev = compressor.Elev; + endJunction.Demand = null; + endJunction.DemandPattern = null; + rhs.Junctions.Add(endJunction); + compressor.EndCode = endJunction.Id; + foreach (var endConnect in endConnectList) + { + var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id); + if (endConnectParter is RevitLink revitLink) + { + if (revitLink.StartCode == compressor.Id) + { + revitLink.StartCode = endJunction.Id; + } + else if (revitLink.EndCode == compressor.Id) + { + revitLink.EndCode = endJunction.Id; + } + } + } + allParterList.Add(endJunction); + + #endregion + } + else + { + msgList.Add($"绌哄帇鏈篬{compressor.Id}]杩炴帴鍒楄〃涓虹┖"); result = false; } } @@ -557,23 +726,23 @@ var startLinkParter = allParterList.Find(x => x.Id == link.StartCode); if (startLinkParter == null) { - msgList.Add($"绠℃:[{link.Code}]涓婃父鑺傜偣閿欒"); + msgList.Add($"绠℃:[{link.Id}]涓婃父鑺傜偣閿欒"); result = false; } else { - link.StartCode = startLinkParter.Code; + link.StartCode = startLinkParter.Id; } var endLinkParter = allParterList.Find(x => x.Id == link.EndCode); if (endLinkParter == null) { - msgList.Add($"绠℃:[{link.Code}]涓嬫父鑺傜偣閿欒"); + msgList.Add($"绠℃:[{link.Id}]涓嬫父鑺傜偣閿欒"); result = false; } else { - link.EndCode = endLinkParter.Code; + link.EndCode = endLinkParter.Id; } } @@ -595,59 +764,55 @@ var allLinks = rhs.GetAllLinks(); foreach (var link in allLinks) { - var startLinkParter = allParterList.Find(x => x.Code == link.StartCode); + var startLinkParter = allParterList.Find(x => x.Id == link.StartCode); if (startLinkParter is RevitLink startLink) { var junction = new Model.RevitJunction(); - junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); - junction.Code = junction.Id; + junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); junction.Name = UniqueHelper.CreateFromFirst("杩炴帴鑺傜偣", allParterList.Select(x => x.Name).Distinct().ToList()); junction.Flags = null; junction.ModelType = null; junction.Description = "姘村姏淇鏃讹紝鑷姩娣诲姞"; - junction.Quality = link.StartQuality; junction.Position = link.StartPosition; - junction.Elev = link.StartElev; + junction.Elev = link.StartPosition.Z; junction.Demand = null; junction.DemandPattern = null; rhs.Junctions.Add(junction); - link.StartCode = junction.Code; + link.StartCode = junction.Id; - if (startLink.StartCode == link.Code) + if (startLink.StartCode == link.Id) { - startLink.StartCode = junction.Code; + startLink.StartCode = junction.Id; } - else if (startLink.EndCode == link.Code) + else if (startLink.EndCode == link.Id) { - startLink.EndCode = junction.Code; + startLink.EndCode = junction.Id; } allParterList.Add(junction); } - var endLinkParter = allParterList.Find(x => x.Code == link.EndCode); + var endLinkParter = allParterList.Find(x => x.Id == link.EndCode); if (endLinkParter is RevitLink endLink) { var junction = new Model.RevitJunction(); - junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); - junction.Code = junction.Id; + junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Id).ToList()); junction.Name = UniqueHelper.CreateFromFirst("杩炴帴鑺傜偣", allParterList.Select(x => x.Name).Distinct().ToList()); junction.Flags = null; junction.ModelType = null; junction.Description = "姘村姏淇鏃讹紝鑷姩娣诲姞"; - junction.Quality = link.EndQuality; junction.Position = link.EndPosition; - junction.Elev = link.EndElev; + junction.Elev = link.EndPosition.Z; junction.Demand = null; junction.DemandPattern = null; rhs.Junctions.Add(junction); - link.EndCode = junction.Code; - if (endLink.StartCode == link.Code) + link.EndCode = junction.Id; + if (endLink.StartCode == link.Id) { - endLink.StartCode = junction.Code; + endLink.StartCode = junction.Id; } - else if (endLink.EndCode == link.Code) + else if (endLink.EndCode == link.Id) { - endLink.EndCode = junction.Code; + endLink.EndCode = junction.Id; } allParterList.Add(junction); } -- Gitblit v1.9.3