Hydro.Core/Common/CheckModel.cs
@@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using static Hydro.Core.ObjectEnum; namespace Hydro.Core.Model { @@ -20,5 +21,10 @@ public class FailModel : BaseModel { public string FailReason { get; set; } public FailType Type { get; set; } public string ModelName { get; set; } } } Hydro.Core/Enum/ObjectEnum.cs
@@ -28,5 +28,13 @@ æµéåçæ²çº¿ = 2, æµéæçæ²çº¿ = 3 } public enum FailType { 缺å°Node1æNode2è¿æ¥å±æ§ = 1, å·å¤´åªè½è¿æ¥ç®¡é = 2, ç¼ºå°æ°´ç®±ææ°´æ± 对象 = 3, 管件对象è¿ç®¡ä»¶å¯¹è±¡ = 4 } } } Hydro.Core/Node/NozzleModel.cs
@@ -22,6 +22,9 @@ /// </summary> public string PatternID { get; set; } public string Node1 { get; set; } public string Node2 { get; set; } public override string ToString() { if (string.IsNullOrEmpty(PatternID)) PatternID = ""; Hydro.Revit/Base/IBaseInterface.cs
@@ -18,5 +18,10 @@ /// </summary> string SystemType { get; set; } /// <summary> /// æ¥¼å± /// </summary> string Floor { get; set; } } } Hydro.Revit/Hydro.Revit2022.csproj
@@ -44,6 +44,7 @@ <Compile Include="Base\IBaseInterface.cs" /> <Compile Include="Model\HydrantBoxViewModel.cs" /> <Compile Include="Model\JunctionViewModel.cs" /> <Compile Include="Model\NetWorkOutViewModel.cs" /> <Compile Include="Model\NozzleViewModel.cs" /> <Compile Include="Model\PipeViewModel.cs" /> <Compile Include="Model\PositionModel.cs" /> Hydro.Revit/Model/HydrantBoxViewModel.cs
@@ -17,5 +17,6 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/Model/JunctionViewModel.cs
@@ -9,11 +9,15 @@ namespace Hydro.Revit.Model { public class JunctionViewModel:JunctionModel,IBaseInterface public class JunctionViewModel : JunctionModel, IBaseInterface { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } public string Node1 { get; set; } public string Node2 { get; set; } public void Draw() { throw new NotImplementedException(); Hydro.Revit/Model/NetWorkOutViewModel.cs
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,39 @@ using Hydro.Core.Model; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Hydro.Revit.Model { public class NetWorkOutViewModel { public long BimFaceID { get; set; } public List<HydrantBoxViewModel> HydrantBoxes { get; set; } = new List<HydrantBoxViewModel>(); public List<JunctionViewModel> Junctions { get; set; } = new List<JunctionViewModel>(); public List<NozzleViewModel> Nozzles { get; set; } = new List<NozzleViewModel>(); public List<PipeViewModel> Pipes { get; set; } = new List<PipeViewModel>(); public List<PumpAdapterViewModel> PumpAdapters { get; set; } = new List<PumpAdapterViewModel>(); public List<ValveViewModel> Valves { get; set; } = new List<ValveViewModel>(); public List<WaterPumpViewModel> Pumps { get; set; } = new List<WaterPumpViewModel>(); public List<WaterTankViewModel> Tanks { get; set; } = new List<WaterTankViewModel>(); public List<ReservoisModel> Reservos { get; set; } = new List<ReservoisModel>(); public List<MeterModel> Meters { get; set; }= new List<MeterModel>(); public List<NodeCalcModel> Nodes { get; set; } = new List<NodeCalcModel>(); public List<LinkCalcModel> Links { get; set; } = new List<LinkCalcModel>(); } } Hydro.Revit/Model/NozzleViewModel.cs
@@ -14,5 +14,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/Model/PipeViewModel.cs
@@ -13,5 +13,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/Model/PumpAdapterViewModel.cs
@@ -14,5 +14,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/Model/ValveViewModel.cs
@@ -12,5 +12,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/Model/WaterPumpViewModel.cs
@@ -12,5 +12,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/Model/WaterTankViewModel.cs
@@ -12,5 +12,7 @@ { public string PositionJson { get; set; } public string SystemType { get; set; } public string Floor { get; set; } } } Hydro.Revit/RevitNetWork.cs
@@ -11,59 +11,79 @@ { public class RevitNetWork : NetWork { public void AddJunction(JunctionViewModel junction) public void AddJunction(JunctionViewModel junction) { CheckNodesExist(junction); Nodes.Add(junction); if (!CheckNodesExist(junction)) Nodes.Add(junction); } public void AddJunctions(List<JunctionViewModel> junctions) public new List<PipeViewModel> Pipes { get { var js = Links.Where(d => d is PipeViewModel); return js?.Select(d => d as PipeViewModel).ToList(); } } public new List<NozzleViewModel> Nozzles { get { var js = Nodes.Where(d => d is NozzleViewModel); return js?.Select(d => d as NozzleViewModel).ToList(); } } public void AddJunctions(List<JunctionViewModel> junctions) { junctions.ForEach(junction => { AddJunction(junction); }); } public void AddTank(WaterTankViewModel tank) public void AddTank(WaterTankViewModel tank) { CheckNodesExist(tank); Nodes.Add(tank); if (!CheckNodesExist(tank)) Nodes.Add(tank); } public void AddTanks(List<WaterTankViewModel> tanks) public List<HydrantBoxViewModel> HydrantBoxes => Nodes.Where((NodeCalcModel d) => d is HydrantBoxViewModel)?.Select((NodeCalcModel d) => d as HydrantBoxViewModel).ToList(); public void AddTanks(List<WaterTankViewModel> tanks) { tanks.ForEach(tank => { AddTank(tank); }); WaterTankViewModel kk=null; Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson); WaterTankViewModels // WaterTankViewModel kk=null; // Nodes.Select(n => (WaterTankViewModel)n).ToList().Sort(o => o.PositionJson); // WaterTankViewModels ((WaterTankViewModel) Nodes[0]).PositionJson //((WaterTankViewModel) Nodes[0]).PositionJson } public void AddPipe(PipeViewModel pipe) public void AddPipe(PipeViewModel pipe) { CheckLinksExist(pipe); Links.Add(pipe); if (!CheckLinksExist(pipe)) Links.Add(pipe); } public void AddPipes(List<PipeViewModel> pipes) public void AddPipes(List<PipeViewModel> pipes) { pipes.ForEach(pipe => { AddPipe(pipe); }); } public void AddPump(WaterPumpViewModel pump) public void AddPump(WaterPumpViewModel pump) { CheckLinksExist(pump); Links.Add(pump); if (!CheckLinksExist(pump)) Links.Add(pump); } public void AddPumps(List<WaterPumpViewModel> pumps) public void AddPumps(List<WaterPumpViewModel> pumps) { pumps.ForEach(pump => { AddPump(pump); }); } public void AddValve(ValveViewModel valve) public void AddValve(ValveViewModel valve) { CheckLinksExist(valve); Links.Add(valve); if (!CheckLinksExist(valve)) Links.Add(valve); } public void AddValves(List<ValveViewModel> valves) @@ -73,35 +93,35 @@ public void AddHydrantBox(HydrantBoxViewModel hydrantBox) { CheckNodesExist(hydrantBox); Nodes.Add(hydrantBox); if (!CheckNodesExist(hydrantBox)) Nodes.Add(hydrantBox); } public void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs) public void AddHydrantBoxs(List<HydrantBoxViewModel> hydrantBoxs) { hydrantBoxs.ForEach(hydrantBox => { AddHydrantBox(hydrantBox); }); } public void AddNozzle(NozzleViewModel nozzle) public void AddNozzle(NozzleViewModel nozzle) { CheckNodesExist(nozzle); Nodes.Add(nozzle); if (!CheckNodesExist(nozzle)) Nodes.Add(nozzle); } public void AddNozzles(List<NozzleViewModel> nozzles) public void AddNozzles(List<NozzleViewModel> nozzles) { nozzles.ForEach(nozzle => { AddNozzle(nozzle); }); } private void CheckNodesExist(NodeCalcModel node) private bool CheckNodesExist(NodeCalcModel node) { if (Nodes.Any(d => d.ID == node.ID)) throw new Exception("å·²åå¨éå¤ç对象"); return Nodes.Any(d => d.ID == node.ID); // throw new Exception("å·²åå¨éå¤ç对象"); } private void CheckLinksExist(LinkCalcModel link) private bool CheckLinksExist(LinkCalcModel link) { if (Links.Any(d => d.ID == link.ID)) throw new Exception("å·²åå¨éå¤ç对象"); return Links.Any(d => d.ID == link.ID); //throw new Exception("å·²åå¨éå¤ç对象"); } } } Test/Program.cs
@@ -17,7 +17,7 @@ const string revitInpPath = "d:\\t2.inp"; static void Main(string[] args) { Test4(); Test3(); } static void Test1() @@ -138,7 +138,7 @@ static void Test3() { var nw = new NetWorkMapModel(); var result = nw.Calc("d:\\revitinp.inp"); var result = nw.Calc("d:\\xiaofang.inp"); Console.WriteLine(result); Console.ReadLine(); }