123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- /* ==============================================================================
- * 功能描述:SagaCheck
- * 创 建 者:Garrett
- * 创建日期:2019/6/11 16:09:09
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using Autodesk.Revit.DB;
- using SAGA.DotNetUtils.Extend;
- using SAGA.DotNetUtils.Logger;
- using ServiceRevitLib.Common;
- using SAGA.RevitUtils.Extends;
- using SAGA.RevitUtils.MEP;
- using ServiceRevitLib.Extend;
- using ServiceRevitLib.Utils;
- namespace ServiceRevitLib.Mode
- {
- /// <summary>
- /// SagaCheck
- /// </summary>
- class SystemReferEquipCheck : CheckBase
- {
- public SystemReferEquipCheck()
- {
- ReferenceSheet = "参考-管网及相关设备";
- }
- public override void Check()
- {
- base.Check();
- #region
- m_EquipReferSystems = DataCheckRule.GetEquipReferSystems();
- var elements = m_Doc.GetEqEcElements();
- foreach (Element element in elements)
- {
- var result = GetCheckResult(element);
- if (result == null) continue;
- Content.Add(result);
- }
- #endregion
- }
- private List<DCR_EquipReferSystem> m_EquipReferSystems;
-
- /// <summary>
- /// 获取检测结果
- /// </summary>
- /// <param name="fi"></param>
- /// <returns></returns>
- private SystemReferEquipCheckResult GetCheckResult(Element element)
- {
- var result = new SystemReferEquipCheckResult();
- var code = element.GetFamilyCode();
- // 可以与设备连接的系统
- var referSystems = m_EquipReferSystems.FirstOrDefault(t => t.EquipName == code)?.Systems ?? new List<string>();
- if (referSystems.Count == 0) return null;
- result.FamilyName = element.GetFamilyName();
- result.Id = element.Id.ToString();
- var tuple = CheckConType(element, referSystems);
- if (tuple.Item2.Any())
- {
- result.ResultMsg = $"连接件所连接的管道系统与规范不一致,请检查";
- result.UnPassSystems += string.Join("、", tuple.Item2.ToArray());
- result.Result = ResultState.Failure;
- }
- else
- {
- result.Result = ResultState.Success;
- }
- result.PassSystems += string.Join("、", tuple.Item1.ToArray());
- return result;
- }
- /// <summary>
- /// 检查连接件连接的管道系统是否符合规范
- /// </summary>
- /// <param name="result">符合要求的系统名称</param>
- /// <param name="domain">不符合要求的系统名称</param>
- private Tuple<List<string>, List<string>> CheckConType(Element element, List<string> referSystems)
- {
- List<string> passList = new List<string>();
- List<string> unpassList = new List<string>();
- var connectors = element.GetAllConnectors();
- foreach (Connector connector in connectors)
- {
- try
- {
- var mepSystem = connector.MEPSystem;
- if (mepSystem == null) continue;
- var elementId = mepSystem.GetTypeId();
- var type = element.Document.GetElement(elementId);
- if (!referSystems.Contains(type.Name))
- {
- unpassList.Add(type.Name);
- }
- else
- {
- passList.Add(type.Name);
- }
- }
- catch (Exception e)
- {
- Log4Net.Info($"读取连接件系统错误。Id:{element.Id},Path:{element.Document.PathName}");
- }
- }
- return new Tuple<List<string>, List<string>>(passList, unpassList);
- }
- }
- }
|