WallExtension.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. public static List<PlanarFace> GetTopFaces(this Wall wall)
  21. {
  22. var solids = Extension.GeometryElementExtension.GetSolids(wall, wall.Document.GetUseView());
  23. //var topZ = wall.GetTopStaticHeight();
  24. //比较最大值不靠谱,取当前面中高度最高的
  25. double topZ = double.MinValue;
  26. List<PlanarFace> faces = new List<PlanarFace>();
  27. foreach (var solid in solids)
  28. {
  29. foreach (Face face in solid.Faces)
  30. {
  31. if (face is PlanarFace planarFace && planarFace.FaceNormal.IsEqual(XYZ.BasisZ))
  32. {
  33. var tempZ = planarFace.Origin.Z;
  34. if (tempZ.IsThan(topZ))
  35. {
  36. faces.Clear();
  37. topZ = tempZ;
  38. faces.Add(planarFace);
  39. }
  40. else if(tempZ.IsEqual(topZ))
  41. {
  42. faces.Add(planarFace);
  43. }
  44. }
  45. }
  46. }
  47. return faces;
  48. }
  49. }
  50. }