Esempio n. 1
0
        private static Autodesk.Revit.DB.Face FindFace(IEnumerable faces, Autodesk.Revit.DB.SpatialElementGeometryResults result, Autodesk.Revit.DB.Curve bCurve)
        {
            foreach (Autodesk.Revit.DB.Face f in faces)
            {
                var boundaryFaces = result.GetBoundaryFaceInfo(f).FirstOrDefault();
                if (boundaryFaces != null && (boundaryFaces.SubfaceType == Autodesk.Revit.DB.SubfaceType.Top ||
                                              boundaryFaces.SubfaceType == Autodesk.Revit.DB.SubfaceType.Bottom))
                {
                    continue; // face is either Top/Bottom so we can skip
                }

                var normal = f.ComputeNormal(new Autodesk.Revit.DB.UV(0.5, 0.5));
                if (normal.IsAlmostEqualTo(Autodesk.Revit.DB.XYZ.BasisZ) || normal.IsAlmostEqualTo(Autodesk.Revit.DB.XYZ.BasisZ.Negate()))
                {
                    continue;                                    // face is either Top/Bottom so we can skip
                }
                var edges = f.GetEdgesAsCurveLoops().First();    // first loop is outer boundary
                if (!edges.Any(x => x.OverlapsWithIn2D(bCurve))) // room's face might be off the floor/level above or offset. if XY matches, we are good.
                {
                    continue;                                    // none of the edges of that face match our curve so we can skip
                }
                return(f);
            }

            return(null);
        }
Esempio n. 2
0
        private static void GetGlazingInfo(
            Autodesk.Revit.DB.Face face,
            Autodesk.Revit.DB.Document doc,
            Autodesk.Revit.DB.SpatialElementGeometryResults result,
            double tolerance,
            out List <List <Autodesk.Revit.DB.XYZ> > glazingPoints,
            out List <double> glazingAreas,
            out List <Element> walls)
        {
            glazingPoints = new List <List <Autodesk.Revit.DB.XYZ> >();
            glazingAreas  = new List <double>();
            walls         = new List <Element>();

            if (!(face is Autodesk.Revit.DB.PlanarFace))
            {
                return;
            }

            var boundaryFaces = result.GetBoundaryFaceInfo(face);

            foreach (var bFace in boundaryFaces)
            {
                var bElement = doc.GetElement(bFace.SpatialBoundaryElement.HostElementId);
                if (bElement is Autodesk.Revit.DB.Wall wall)
                {
                    walls.Add(bElement.ToDSType(true));

                    if (wall.WallType.Kind == Autodesk.Revit.DB.WallKind.Curtain)
                    {
                        GetGlazingFromCurtainWall(wall, face, tolerance, ref glazingPoints, ref glazingAreas);
                    }
                    else
                    {
                        GetGlazingFromWindows(wall, face, tolerance, ref glazingPoints, ref glazingAreas);
                    }
                }
            }
        }