| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using Autodesk.Revit.UI;
- using SAGA.DotNetUtils.Extend;
- using SAGA.GplotDrawData;
- using SAGA.GplotRelationComputerManage;
- using SAGA.Models;
- using SAGA.RevitUtils.Windows;
- namespace SAGA.GplotManage.UploadRelated {
- /// <summary>
- /// 空调冷却水
- /// </summary>
- class CoolingWaterLoop : Gplot {
- public override GraphTypeEnum GraphType => GraphTypeEnum.CoolingWaterLoop;
- public override Type DataType => typeof(LogicNode);
- protected override void DealUploadData() {
- //查找夏天冷却水
- string name = $"{CsSeasonType.Summer.GetDescription()}-{CsSystemType.CoolingWater.GetDescription()}";
- //取出冷站冷却水
- var dn = DrawDataServer.GetLogicNode()?.Nodes.FirstOrDefault(t => t.Name == name);
- if (dn != null)
- {
- DrawNode(dn);
- }
- }
- private void DrawNode(LogicNode ln1) {
- //避免移除数据对原始数据造成影响
- var ln = new LogicNode { Name = ln1.Name };
- ln1.Nodes.ForEach(ln.Nodes.Add);
- if (ln.Nodes.Count == 0) return;
- var node = ln.Nodes[0];
- var lastIds = new List<string>();
- for (int i = 0; i < ln.Nodes.Count; i++) {
- var currIds = new List<string>();
- //当前节点为子节点
- if (node.Nodes.Count == 0) {
- continue;
- }
- //当前节点的子节点也包含子节点
- if (node.Nodes.Any(t => t.Nodes.Count > 0)) {
- DrawNode(node);
- continue;
- }
- var m = node.Nodes.Count;
- var regStr = "地源热泵|供冷冷却水泵|供冷冷冻水泵|地埋管";
- var ids = node.Nodes.Select(t1 => {
- var elment = t1.Elements.FirstOrDefault(t => Regex.IsMatch(t.FamilyName ?? "", regStr));
- return elment != null ? elment.Id : "";
- }).ToList();
- if (node.RelationType == ChildrenRelationType.ParallelCon) {
- currIds.AddRange(ids);
- }
- else if (node.RelationType == ChildrenRelationType.SeriesCon) {
- //取出最后一个作为连接点
- currIds.Add(ids.LastOrDefault());
- //设备串联
- for (int j = 0; j < m - 1; j++) {
- Criterias.criterias.Add(GetReleateData(ids[j], ids[j + 1]));
- }
- }
- if (lastIds.Count > 0)
- {
- foreach (var lastId in lastIds)
- {
- foreach (var currId in currIds)
- {
- Criterias.criterias.Add(GetReleateData(lastId, currId));
- }
- }
- }
- lastIds.Clear();
- lastIds.AddRange(currIds);
- //移除当前元素,避免查找污染
- ln.Nodes.Remove(node);
- i--;
- node = ln.Nodes.FirstOrDefault(t => IsConnector(t, node));
- if (node == null) break;
- }
- }
- public bool IsConnector(LogicNode node1, LogicNode node2) {
- if (node1 == null || node2 == null) return false;
- if (node1 == node2) return false;
- return node1.RealNodes.Any(n => node2.RealNodes.
- Any(n1 => n.ToString() == n1.ToString()));
- }
- public override void Computer()
- {
- throw new NotImplementedException();
- }
- public override void Show(GplotShowType showType)
- {
- throw new NotImplementedException();
- }
- }
- /// <summary>
- /// 冷冻水管道平面
- /// </summary>
- public class ChillWaterLoop_V : Gplot
- {
- public override Type DataType => typeof(AcWater);
- public override GraphTypeEnum GraphType => GraphTypeEnum.ChillWaterLoop_V;
- public override void Computer()
- {
- ComputerPipes.Computer();
- }
- [CheckAndKeepGplotLaster]
- public override void Show(GplotShowType showType = GplotShowType.Default)
- {
-
- }
- protected override void DealUploadData()
- {
-
- }
- }
- }
|