示例#1
0
        public static Surface ExtractSurface(Autodesk.Revit.DB.PlanarFace face, IEnumerable<PolyCurve> edgeLoops)
        {
            edgeLoops = edgeLoops.ToList();

            var x = face.get_Vector(0).ToVector(false);
            var y = face.get_Vector(1).ToVector(false);

            // Construct planar surface larger than the biggest edge loop
            var or = edgeLoops.First().StartPoint; // don't use origin provided by revit, could be anywhere
            var maxLength = edgeLoops.Max(pc => pc.Length);
            var bigx = x.Scale(maxLength * 2);
            var bigy = y.Scale(maxLength * 2);

            return Surface.ByPerimeterPoints(new[] {    or.Subtract(bigx).Subtract(bigy), 
                                                        or.Add(bigx).Subtract(bigy), 
                                                        or.Add(bigx).Add(bigy),
                                                        or.Subtract(bigx).Add(bigy) });
        }