EquipPartLocationCheck.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* ==============================================================================
  2. * 功能描述:SagaCheck
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/6/11 16:09:09
  5. * ==============================================================================*/
  6. using System;
  7. using System.Linq;
  8. using Autodesk.Revit.DB;
  9. using ServiceRevitLib.Extend;
  10. using ServiceRevitLib.Mode;
  11. namespace ServiceRevitLib.DataCheck.Mode
  12. {
  13. /// <summary>
  14. /// SagaCheck
  15. /// </summary>
  16. class EquipPartLocationCheck : CheckBase
  17. {
  18. public override void Check()
  19. {
  20. try
  21. {
  22. base.Check();
  23. #region
  24. var document = m_Doc;
  25. var elements = document.GetEqEcElements();
  26. var parts = elements.Where(t => t.IsEquipmentPart());
  27. foreach (Element fi in parts)
  28. {
  29. var result = new EquipPartLocationCheckResult();
  30. result.PartFamilyName = fi.GetFamilyName();
  31. result.PartId = fi.Id.ToString();
  32. var partParent = fi.GetPartParent();
  33. if (partParent == null)
  34. {
  35. result.Result = ResultState.Failure;
  36. result.ResultMsg = "未与设备相交,请检查";
  37. }
  38. else
  39. {
  40. result.Result = ResultState.Success;
  41. result.ResultMsg = $"关联设备的id为{partParent.Id}";
  42. }
  43. Content.Add(result);
  44. }
  45. #endregion
  46. }
  47. catch (Exception e)
  48. {
  49. Result = ResultState.Failure;
  50. ResultMsg = $"{e.Message}\r\n{e.StackTrace}";
  51. }
  52. }
  53. }
  54. }