Beispiel #1
0
        public static List <List <Revit.Elements.Element> > ElevationInRoom(List <Revit.Elements.Room> Rooms, Revit.Elements.Element FloorPlan, double Offset = 500)
        {
            var doc           = DocumentManager.Instance.CurrentDBDocument;
            var vtype         = new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)).Cast <ViewFamilyType>().FirstOrDefault(a => a.ViewFamily == ViewFamily.Elevation);
            var ElevationView = new List <List <Revit.Elements.Element> >();

            TransactionManager.Instance.EnsureInTransaction(doc);
            foreach (var r in Rooms)
            {
                var    list      = new List <Revit.Elements.Element>();
                var    elevViews = new List <Revit.Elements.Element>();
                String rname     = r.InternalElement.LookupParameter("Number").AsString() + "_" + r.InternalElement.LookupParameter("Name").AsString();

                LocationPoint   elevPoint = (Autodesk.Revit.DB.LocationPoint)r.InternalElement.Location;
                XYZ             point     = elevPoint.Point;
                BoundingBoxXYZ  bbox      = r.InternalElement.get_BoundingBox(doc.ActiveView);
                ElevationMarker marker    = Autodesk.Revit.DB.ElevationMarker.CreateElevationMarker(doc, vtype.Id, point, 50);

                BoundingBoxXYZ bcrop    = Utility.crop_box(bbox, Offset / 304.8);
                var            surfaces = bcrop.ToProtoType(true).ToPolySurface().Surfaces().Skip(2).Take(4);

                var westElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 0);
                westElev.Name = rname + " - A";
                var westcrsm  = westElev.GetCropRegionShapeManager();
                var west      = surfaces.ElementAt(0).PerimeterCurves();
                var westcurve = new List <Autodesk.Revit.DB.Curve>();
                foreach (var w in west)
                {
                    westcurve.Add(w.ToRevitType(true));
                }
                CurveLoop wcloop = CurveLoop.Create(westcurve);
                westcrsm.SetCropShape(wcloop);

                var northElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 1);
                northElev.Name = rname + " - B";
                var northcrsm  = northElev.GetCropRegionShapeManager();
                var north      = surfaces.ElementAt(1).PerimeterCurves();
                var northcurve = new List <Autodesk.Revit.DB.Curve>();
                foreach (var w in north)
                {
                    northcurve.Add(w.ToRevitType(true));
                }
                CurveLoop ncloop = CurveLoop.Create(northcurve);
                northcrsm.SetCropShape(ncloop);

                var eastElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 2);
                eastElev.Name = rname + " - C";
                var eastcrsm  = eastElev.GetCropRegionShapeManager();
                var east      = surfaces.ElementAt(2).PerimeterCurves();
                var eastcurve = new List <Autodesk.Revit.DB.Curve>();
                foreach (var w in east)
                {
                    eastcurve.Add(w.ToRevitType(true));
                }
                CurveLoop ecloop = CurveLoop.Create(eastcurve);
                eastcrsm.SetCropShape(ecloop);

                var southElev = marker.CreateElevation(doc, FloorPlan.InternalElement.Id, 3);
                southElev.Name = rname + " - D";
                var southcrsm  = southElev.GetCropRegionShapeManager();
                var south      = surfaces.ElementAt(3).PerimeterCurves();
                var southcurve = new List <Autodesk.Revit.DB.Curve>();
                foreach (var w in south)
                {
                    southcurve.Add(w.ToRevitType(true));
                }
                CurveLoop scloop = CurveLoop.Create(southcurve);
                southcrsm.SetCropShape(scloop);

                list.Add(westElev.ToDSType(true));
                list.Add(northElev.ToDSType(true));
                list.Add(eastElev.ToDSType(true));
                list.Add(southElev.ToDSType(true));

                ElevationView.Add(list);
            }
            TransactionManager.Instance.TransactionTaskDone();
            return(ElevationView);
        }