| | |
| | | using HStation.Model; |
| | | using Microsoft.VisualBasic; |
| | | using System; |
| | | |
| | | namespace HStation.Service |
| | | { |
| | |
| | | public static class RevitCorrectHelper |
| | | { |
| | | /// <summary> |
| | | /// 修正(无法修正会抛出异常) |
| | | /// 修正 |
| | | /// </summary> |
| | | /// <param name="rhs">RevitModel</param> |
| | | public static bool Correct(this Model.RevitModel rhs, out string msg) |
| | | { |
| | | if (rhs == null) |
| | |
| | | private static bool Zero(Model.RevitModel rhs, out string msg) |
| | | { |
| | | msg = string.Empty; |
| | | var allWaterSourceList = rhs.GetAllWaterSources(); |
| | | var allWaterSourceList = rhs.GetAllSources(); |
| | | if (allWaterSourceList == null || allWaterSourceList.Count < 1) |
| | | { |
| | | msg = "无水源"; |
| | |
| | | { |
| | | if (exchanger.ConnectList != null && exchanger.ConnectList.Count > 0) |
| | | { |
| | | foreach (var connect in exchanger.ConnectList) |
| | | foreach (var connect in exchanger.ConnectList.ToList()) |
| | | { |
| | | var connectParter = allParterList.Find(x => x.Id == connect.Id); |
| | | if (connectParter == null) |
| | | { |
| | | msg = $"换热器:{exchanger.Id} 连接组件 {connect.Id} 不存在"; |
| | | return false; |
| | | exchanger.ConnectList.Remove(connect); |
| | | } |
| | | else |
| | | { |
| | | if (connectParter is RevitBlunthead blunthead) |
| | | { |
| | | var decorator = new Model.RevitDecorator(); |
| | | decorator.Id = blunthead.Id; |
| | | decorator.Code = blunthead.Code; |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | foreach (var startConnect in startConnectList) |
| | | { |
| | | var startConnectParter = allParterList.Find(x => x.Id == startConnect.Id); |
| | | if (startConnectParter is IRevitLink revitLink) |
| | | if (startConnectParter is RevitLink revitLink) |
| | | { |
| | | if (revitLink.StartCode == exchanger.Id) |
| | | { |
| | |
| | | foreach (var endConnect in endConnectList) |
| | | { |
| | | var endConnectParter = allParterList.Find(x => x.Id == endConnect.Id); |
| | | if (endConnectParter is IRevitLink revitLink) |
| | | if (endConnectParter is RevitLink revitLink) |
| | | { |
| | | if (revitLink.StartCode == exchanger.Id) |
| | | { |
| | |
| | | foreach (var link in allLinks) |
| | | { |
| | | var startLinkParter = allParterList.Find(x => x.Code == link.StartCode); |
| | | if (startLinkParter is IRevitLink startLink) |
| | | if (startLinkParter is RevitLink startLink) |
| | | { |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); |
| | |
| | | rhs.Junctions.Add(junction); |
| | | link.StartCode = junction.Code; |
| | | |
| | | if (startLink.StartCode == link.StartCode) |
| | | if (startLink.StartCode == link.Code) |
| | | { |
| | | startLink.StartCode = junction.Code; |
| | | } |
| | | else if (startLink.EndCode == link.StartCode) |
| | | else if (startLink.EndCode == link.Code) |
| | | { |
| | | startLink.EndCode = junction.Code; |
| | | } |
| | |
| | | } |
| | | |
| | | var endLinkParter = allParterList.Find(x => x.Code == link.EndCode); |
| | | if (endLinkParter is IRevitLink endLink) |
| | | if (endLinkParter is RevitLink endLink) |
| | | { |
| | | var junction = new Model.RevitJunction(); |
| | | junction.Id = Yw.Untity.UniqueHelper.CreateFromFirst("junction", allParterList.Select(x => x.Code).ToList()); |
| | |
| | | junction.DemandPattern = null; |
| | | rhs.Junctions.Add(junction); |
| | | link.EndCode = junction.Code; |
| | | if (endLink.StartCode == link.EndCode) |
| | | if (endLink.StartCode == link.Code) |
| | | { |
| | | endLink.StartCode = junction.Code; |
| | | } |
| | | else if (endLink.EndCode == link.EndCode) |
| | | else if (endLink.EndCode == link.Code) |
| | | { |
| | | endLink.EndCode = junction.Code; |
| | | } |