/*------------------------------------------------------------------------- * 功能描述:WallExtension * 作者:xulisong * 创建时间: 2019/6/26 17:57:20 * 版本号:v1.0 * -------------------------------------------------------------------------*/ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.DB; using SAGA.DotNetUtils.Extend; using SAGA.RevitUtils; using SAGA.RevitUtils.Extends; namespace RevitToJBim.Extension { public static class WallExtension { public static List GetTopFaces(this Wall wall) { var solids = Extension.GeometryElementExtension.GetSolids(wall, wall.Document.GetUseView()); //var topZ = wall.GetTopStaticHeight(); //比较最大值不靠谱,取当前面中高度最高的 double topZ = double.MinValue; List faces = new List(); foreach (var solid in solids) { foreach (Face face in solid.Faces) { if (face is PlanarFace planarFace && planarFace.FaceNormal.IsEqual(XYZ.BasisZ)) { var tempZ = planarFace.Origin.Z; if (tempZ.IsThan(topZ)) { faces.Clear(); topZ = tempZ; faces.Add(planarFace); } else if(tempZ.IsEqual(topZ)) { faces.Add(planarFace); } } } } return faces; } } }