SystemNameCheck.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* ==============================================================================
  2. * 功能描述:SagaCheck
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/6/11 16:09:09
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text.RegularExpressions;
  10. using Autodesk.Revit.DB;
  11. using Autodesk.Revit.DB.Mechanical;
  12. using SAGA.DotNetUtils.Extend;
  13. using ServiceRevitLib.Common;
  14. using SAGA.RevitUtils.Extends;
  15. using SAGA.RevitUtils.MEP;
  16. using ServiceRevitLib.Extend;
  17. using ServiceRevitLib.Utils;
  18. namespace ServiceRevitLib.Mode
  19. {
  20. /// <summary>
  21. /// SagaCheck
  22. /// </summary>
  23. class SystemNameCheck : CheckBase
  24. {
  25. public SystemNameCheck()
  26. {
  27. ReferenceSheet = "参考-可识别的系统名称";
  28. }
  29. public override void Check()
  30. {
  31. base.Check();
  32. #region
  33. m_MEPSystems = DataCheckRule.GetMepSystems();
  34. var mepsystemTypes = new List<MEPSystemType>();
  35. mepsystemTypes.AddRange(m_Doc.GetMechanicalSystemTypes());
  36. mepsystemTypes.AddRange(m_Doc.GetPipingSystemTypes());
  37. foreach (var t in mepsystemTypes)
  38. {
  39. var result = GetCheckResult(t);
  40. Content.Add(result);
  41. }
  42. #endregion
  43. }
  44. private List<DCR_MEPSystem> m_MEPSystems;
  45. /// <summary>
  46. /// 获取检测结果
  47. /// </summary>
  48. /// <param name="fi"></param>
  49. /// <returns></returns>
  50. private SystemNameCheckResult GetCheckResult(MEPSystemType system)
  51. {
  52. var result = new SystemNameCheckResult();
  53. string systemName = system.Name;
  54. result.SystemName = systemName;
  55. result.SystemType = system is MechanicalSystemType ? "风管系统" : "管道系统";
  56. var item = m_MEPSystems.Where(t => SystemNameIsEqual(systemName, t.Name));
  57. if (item.Any())
  58. {
  59. result.Result = ResultState.Success;
  60. }
  61. else
  62. {
  63. result.Result = ResultState.Failure;
  64. result.ResultMsg = $"未知的系统名称,请按照系统类型命名规范修改";
  65. }
  66. return result;
  67. }
  68. /// <summary>
  69. /// 系统名称相等,模型中的系统名称包含就定义名称即可
  70. /// </summary>
  71. /// <param name="originName"></param>
  72. /// <param name="targetName"></param>
  73. /// <returns></returns>
  74. private bool SystemNameIsEqual(string originName, string targetName)
  75. {
  76. bool result = false;
  77. string n1 = originName.ToLower();
  78. string n2 = targetName.ToLower();
  79. return n1.Equals(n2);
  80. }
  81. }
  82. }