EquipInSpaceCheck.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 Autodesk.Revit.DB;
  10. using Autodesk.Revit.DB.Mechanical;
  11. using SAGA.RevitUtils.Extends;
  12. using ServiceRevitLib.Extend;
  13. using ServiceRevitLib.Mode;
  14. namespace ServiceRevitLib.DataCheck.Mode
  15. {
  16. /// <summary>
  17. /// SagaCheck
  18. /// </summary>
  19. class EquipInSpaceCheck : CheckBase
  20. {
  21. public override void Check()
  22. {
  23. try
  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. catch (Exception e)
  38. {
  39. Result = ResultState.Failure;
  40. ResultMsg = $"{e.Message}\r\n{e.StackTrace}";
  41. }
  42. }
  43. /// <summary>
  44. /// 获取检测结果
  45. /// </summary>
  46. /// <param name="fi"></param>
  47. /// <returns></returns>
  48. private EquipInSpaceCheckResult GetCheckResult(Element fi, List<Space> spaces)
  49. {
  50. var result = new EquipInSpaceCheckResult();
  51. result.FamilyName = fi.GetFamilyName();
  52. result.Id = fi.Id.ToString();
  53. var space = fi.GetReferenceSpace(spaces);
  54. if (space != null)
  55. {
  56. result.SpaceId = space.Id.ToString();
  57. result.Result = ResultState.Success;
  58. }
  59. else
  60. {
  61. result.Result = ResultState.Failure;
  62. result.ResultMsg = "请检查设备是否在空间中";
  63. }
  64. return result;
  65. }
  66. }
  67. }