UnitCheck.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* ==============================================================================
  2. * 功能描述:SagaCheck
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/6/11 16:09:09
  5. * ==============================================================================*/
  6. using System;
  7. using Autodesk.Revit.DB;
  8. namespace ServiceRevitLib.Mode
  9. {
  10. /// <summary>
  11. /// SagaCheck
  12. /// </summary>
  13. class UnitCheck : CheckBase
  14. {
  15. public override void Check()
  16. {
  17. base.Check();
  18. #region
  19. string resultMsg =null;
  20. ResultState resultState = ResultState.Failure;
  21. string unit = "";
  22. var formatOptions = m_Doc.GetUnits().GetFormatOptions(UnitType.UT_Length);
  23. var ismmUnit= formatOptions.DisplayUnits == DisplayUnitType.DUT_MILLIMETERS;
  24. unit = formatOptions.DisplayUnits.ToString();
  25. if (!ismmUnit)
  26. {
  27. resultMsg = "单位异常,请修改长度单位为毫米(mm)";
  28. resultState = ResultState.Failure;
  29. }
  30. else
  31. {
  32. resultState = ResultState.Success;
  33. }
  34. Content.Add(new UnitCheckResult() { Unit = unit, Result = resultState, ResultMsg = resultMsg });
  35. #endregion
  36. }
  37. }
  38. }