SpaceExtend.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* ==============================================================================
  2. * 功能描述:SpaceExtend
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/12/6 14:52:05
  5. * ==============================================================================*/
  6. using Autodesk.Revit.DB;
  7. using Autodesk.Revit.DB.Mechanical;
  8. using RevitToJBim.MBI;
  9. using SAGA.DotNetUtils.Extend;
  10. using SAGA.RevitUtils.Extends;
  11. namespace RevitToJBim.Extension
  12. {
  13. /// <summary>
  14. /// SpaceExtend
  15. /// </summary>
  16. public static class SpaceExtend
  17. {
  18. /// <summary>
  19. /// 手动删除的空间,仅在明细表中可见
  20. /// </summary>
  21. /// <param name="space"></param>
  22. /// <returns></returns>
  23. public static bool IsDeleteSpace(this Space space)
  24. {
  25. //周长
  26. double perimeter = space.Perimeter;
  27. //面积
  28. double area = space.Area;
  29. //空间比较特殊,周长为零就相当于删除
  30. return (perimeter.IsZero(MBIConst.SpacePerimeterTolerance)) || (area.IsZero(MBIConst.SpaceAreaTolerance));
  31. }
  32. /// <summary>
  33. /// 获取空间的默认名称
  34. /// 如果空间名称为“空间”或者为“”则显示Name
  35. /// 否则显示Room_Name
  36. /// </summary>
  37. /// <param name="space"></param>
  38. /// <returns></returns>
  39. public static string GetSpaceDefaultName(this Space space)
  40. {
  41. string defaultName = space.Name;
  42. var roomname = space.GetParameterString(BuiltInParameter.ROOM_NAME);
  43. if (roomname == "空间" || roomname.IsNullOrEmptyExt()) return defaultName;
  44. defaultName = roomname;
  45. return defaultName;
  46. }
  47. }
  48. }