/* ============================================================================== * 功能描述: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 Autodesk.Revit.DB.Mechanical; using SAGA.DotNetUtils.Extend; using ServiceRevitLib.Common; using SAGA.RevitUtils.Extends; using SAGA.RevitUtils.MEP; using ServiceRevitLib.Extend; using ServiceRevitLib.Utils; namespace ServiceRevitLib.Mode { /// /// SagaCheck /// class SystemNameCheck : CheckBase { public SystemNameCheck() { ReferenceSheet = "参考-可识别的系统名称"; } public override void Check() { base.Check(); #region m_MEPSystems = DataCheckRule.GetMepSystems(); var mepsystemTypes = new List(); mepsystemTypes.AddRange(m_Doc.GetMechanicalSystemTypes()); mepsystemTypes.AddRange(m_Doc.GetPipingSystemTypes()); foreach (var t in mepsystemTypes) { var result = GetCheckResult(t); Content.Add(result); } #endregion } private List m_MEPSystems; /// /// 获取检测结果 /// /// /// private SystemNameCheckResult GetCheckResult(MEPSystemType system) { var result = new SystemNameCheckResult(); string systemName = system.Name; result.SystemName = systemName; result.SystemType = system is MechanicalSystemType ? "风管系统" : "管道系统"; var item = m_MEPSystems.Where(t => SystemNameIsEqual(systemName, t.Name)); if (item.Any()) { result.Result = ResultState.Success; } else { result.Result = ResultState.Failure; result.ResultMsg = $"未知的系统名称,请按照系统类型命名规范修改"; } return result; } /// /// 系统名称相等,模型中的系统名称包含就定义名称即可 /// /// /// /// private bool SystemNameIsEqual(string originName, string targetName) { bool result = false; string n1 = originName.ToLower(); string n2 = targetName.ToLower(); return n1.Equals(n2); } } }