123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /* ==============================================================================
- * 功能描述:管网检查
- * 创 建 者:Garrett
- * 创建日期:2019/6/11 16:09:09
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Linq;
- using Autodesk.Revit.DB;
- using SAGA.DotNetUtils.Extend;
- using SAGA.RevitUtils.Extends;
- using SAGA.RevitUtils.MEP;
- using ServiceRevitLib.Extend;
- using ServiceRevitLib.Mode;
- namespace ServiceRevitLib.DataCheck.Mode
- {
- /// <summary>
- /// SagaCheck
- /// </summary>
- class PipeCheck : CheckBase
- {
- public override void Check()
- {
- try
- {
- base.Check();
- #region
- var document = m_Doc;
- var elements = document.FilterElements<MEPCurve>().ToList();
- foreach (var element in elements)
- {
- if (element.IsStart())
- {
- //标记立管,所有连接点都未记录则删除
- //if (!connectors.Any(c => c.IsConnected))
- //{
- // item.ErrorCode = "001";
- // reportItem.ResultItems.Add(item);
- //}
- continue;
- }
- var item = new PipeCheckResult();
- item.SystemName = element.GetSystemTypeName();
- item.Id = element.Id.ToString();
- var code = GetErrorCode(element, item.SystemName);
- if (IsNeedExport(code))
- {
- item.Result = ResultState.Failure;
- item.ResultMsg = GetErrorDescription(code);
- Content.Add(item);
- }
- }
- #endregion
- }
- catch (Exception e)
- {
- Result = ResultState.Failure;
- ResultMsg = $"{e.Message}\r\n{e.StackTrace}";
- }
-
- }
- /// <summary>
- /// 获取错误码
- /// </summary>
- /// <param name="element"></param>
- /// <param name="systemName"></param>
- /// <returns></returns>
- private PipeCheckErrorCode GetErrorCode(Element element,string systemName)
- {
- PipeCheckErrorCode errorCode = PipeCheckErrorCode.Code_000;
- Domain[] domains = new Domain[] { Domain.DomainPiping, Domain.DomainHvac };
- do
- {
- foreach (Domain domain in domains)
- {
- var connectors = element.GetConnectors(domain);
- if (connectors.Any(c => !c.IsConnected))
- {
- errorCode = PipeCheckErrorCode.Code_001;
- }
- }
- if (errorCode == PipeCheckErrorCode.Code_001 && element.GetLocationCurve() is Line line)
- {
- //一端不连接的立管不导出
- if (line.Direction.IsParallel(XYZ.BasisZ))
- {
- errorCode = PipeCheckErrorCode.Code_003;
- }
- }
- var endElements = element.GetFirstElements(null, e => e is MEPCurve || e.IsEquipment());
- List<MEPCurve> curves = endElements.OfType<MEPCurve>().ToList();
- foreach (var mepCurve in curves)
- {
- if (systemName != mepCurve.GetSystemTypeName())
- {
- errorCode = PipeCheckErrorCode.Code_002;
- break;
- }
- }
- } while (false);
- return errorCode;
- }
- /// <summary>
- /// 获取错误描述
- /// </summary>
- /// <param name="errorCode"></param>
- /// <returns></returns>
- private string GetErrorDescription(PipeCheckErrorCode errorCode)
- {
- string description = errorCode.GetDescription()+",请检查";
- return description;
- }
- /// <summary>
- /// 是否需要导出
- /// </summary>
- /// <param name="errorCode"></param>
- /// <returns></returns>
- private bool IsNeedExport(PipeCheckErrorCode errorCode)
- {
- return errorCode == PipeCheckErrorCode.Code_001 || errorCode == PipeCheckErrorCode.Code_002;
- }
- enum PipeCheckErrorCode
- {
- [Description("管段连接正确")]
- Code_000,
- [Description("末端未连接任何设备")]
- Code_001,
- [Description("管道两端连接了不同类型的管道")]
- Code_002,
- Code_003,
- [Description("误报")]
- Code_004
- }
- }
- }
|