WallExtension.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:WallExtension
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/26 17:57:20
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Autodesk.Revit.DB;
  13. using SAGA.DotNetUtils.Extend;
  14. using SAGA.RevitUtils;
  15. using SAGA.RevitUtils.Extends;
  16. namespace RevitToJBim.Extension
  17. {
  18. public static class WallExtension
  19. {
  20. /// <summary>
  21. /// 获取墙底面的轮廓,主要处理门窗分割墙问题
  22. /// </summary>
  23. /// <param name="wall"></param>
  24. /// <returns></returns>
  25. public static List<PlanarFace> GetBottomFaces(this Wall wall)
  26. {
  27. var solids = Extension.GeometryElementExtension.GetSolids(wall);
  28. //var topZ = wall.GetTopStaticHeight();
  29. double volume = double.MinValue;
  30. List<PlanarFace> faces = new List<PlanarFace>();
  31. foreach (var solid in solids)
  32. {
  33. var tempVolume = solid.Volume;
  34. double topZ = double.MaxValue;
  35. //取体积最大的Solid
  36. if (tempVolume.IsThan(volume))
  37. {
  38. volume = tempVolume;
  39. faces.Clear();
  40. }
  41. else
  42. {
  43. continue;
  44. }
  45. foreach (Face face in solid.Faces)
  46. {
  47. if (face is PlanarFace planarFace && planarFace.FaceNormal.IsEqual(-XYZ.BasisZ))
  48. {
  49. var tempZ = planarFace.Origin.Z;
  50. //取底面FaceNormal为(0,0,-1),Z最小
  51. if (tempZ.IsLess(topZ))
  52. {
  53. faces.Clear();
  54. topZ = tempZ;
  55. faces.Add(planarFace);
  56. }
  57. else if(tempZ.IsEqual(topZ))
  58. {
  59. faces.Add(planarFace);
  60. }
  61. }
  62. }
  63. }
  64. return faces;
  65. }
  66. }
  67. }