EquipInSpaceCheck.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 ServiceRevitLib.Extend;
  16. namespace ServiceRevitLib.Mode
  17. {
  18. /// <summary>
  19. /// SagaCheck
  20. /// </summary>
  21. class EquipInSpaceCheck : CheckBase
  22. {
  23. public override void Check()
  24. {
  25. base.Check();
  26. #region
  27. var document = m_Doc;
  28. var elements = document.GetEqEcElements();
  29. var rspaces = document.GetSpaces().Where(t => t.IsValidObject).ToList();
  30. foreach (Element fi in elements)
  31. {
  32. var result = GetCheckResult(fi, rspaces);
  33. Content.Add(result);
  34. }
  35. #endregion
  36. }
  37. /// <summary>
  38. /// 获取检测结果
  39. /// </summary>
  40. /// <param name="fi"></param>
  41. /// <returns></returns>
  42. private EquipInSpaceCheckResult GetCheckResult(Element fi, List<Space> spaces)
  43. {
  44. var result = new EquipInSpaceCheckResult();
  45. result.FamilyName = fi.GetFamilyName();
  46. result.Id = fi.Id.ToString();
  47. var space = fi.GetReferenceSpace(spaces);
  48. if (space != null)
  49. {
  50. result.SpaceId = space.Id.ToString();
  51. result.Result = ResultState.Success;
  52. }
  53. else
  54. {
  55. result.Result = ResultState.Failure;
  56. result.ResultMsg = "请检查设备是否在空间中";
  57. }
  58. return result;
  59. }
  60. }
  61. }