Ejemplo n.º 1
0
        public void GetAverageBuildingFromMasses(Document doc, int nFloors, IDFFile.BuildingConstruction constructions,
                                                 IDFFile.WWR WWR, IDFFile.BuildingOperation buildingOperations, out Dictionary <string, Element> masses)
        {
            AvgBuildings = new Dictionary <string, IDFFile.Building>();
            masses       = new Dictionary <string, Element>();
            List <View3D> views = (new FilteredElementCollector(doc).OfClass(typeof(View3D)).Cast <View3D>()).Where(v => v.Name.Contains("Op - ")).ToList();

            foreach (View3D v1 in views)
            {
                //Initialize building elements
                FilteredElementCollector massElement  = new FilteredElementCollector(doc, v1.Id).WhereElementIsNotElementType().OfCategory(BuiltInCategory.OST_Mass);
                List <IDFFile.XYZ>       groundPoints = new List <IDFFile.XYZ>();
                List <IDFFile.XYZ>       roofPoints   = new List <IDFFile.XYZ>();
                double floorArea = 0;
                foreach (Element mass in massElement)
                {
                    Options op = new Options()
                    {
                        ComputeReferences = true
                    };
                    GeometryElement gElement = mass.get_Geometry(op);
                    foreach (GeometryObject SolidStructure in gElement)
                    {
                        Solid GeoObject = SolidStructure as Solid;
                        if (GeoObject != null)
                        {
                            FaceArray AllFacesFromModel = GeoObject.Faces;
                            if (AllFacesFromModel.Size != 0)
                            {
                                foreach (Face face1 in AllFacesFromModel)
                                {
                                    XYZ fNormal = (face1 as PlanarFace).FaceNormal;

                                    //checks if it is indeed a wall by computing the normal with respect to 001
                                    if (Math.Round(fNormal.Z, 3) == -1)
                                    {
                                        groundPoints.AddRange(Utility.GetPoints(face1));
                                        floorArea = Utility.SqFtToSqM(face1.Area);
                                    }
                                    if (Math.Round(fNormal.Z, 3) == 1)
                                    {
                                        roofPoints.AddRange(Utility.GetPoints(face1));
                                    }
                                }
                            }
                        }
                    }
                    masses.Add(v1.Name.Remove(0, 5), mass);
                }
                IDFFile.Building building = InitialiseModelBuilding(groundPoints, roofPoints, floorArea, nFloors, constructions, WWR, buildingOperations);
                AvgBuildings.Add(v1.Name.Remove(0, 5), building);
            }
        }
Ejemplo n.º 2
0
        public static IDFFile.Building InitialiseModelBuilding(List <IDFFile.XYZ> groundPoints, List <IDFFile.XYZ> roofPoints, double area, int nFloors,
                                                               IDFFile.BuildingConstruction constuction, IDFFile.WWR wwr, IDFFile.BuildingOperation operation)
        {
            IDFFile.ZoneList zoneList = new IDFFile.ZoneList("Office");

            double[] heatingSetPoints    = new double[] { 10, 20 };
            double[] coolingSetPoints    = new double[] { 28, 24 };
            double   equipOffsetFraction = 0.1;

            IDFFile.Building bui = new IDFFile.Building
            {
                buildingConstruction = constuction,
                WWR = wwr,
                buildingOperation = operation
            };
            bui.UpdataBuildingOperations();
            bui.CreateSchedules(heatingSetPoints, coolingSetPoints, equipOffsetFraction);
            bui.GenerateConstructionWithIComponentsU();
            IDFFile.ScheduleCompact Schedule = bui.schedulescomp.First(s => s.name.Contains("Occupancy"));

            double baseZ    = groundPoints.First().Z;
            double roofZ    = roofPoints.First().Z;
            double heightFl = (roofZ - baseZ) / nFloors;

            IDFFile.XYZList dlPoints = Utility.GetDayLightPointsXYZList(groundPoints, Utility.GetAllWallEdges(groundPoints));
            for (int i = 0; i < nFloors; i++)
            {
                double          floorZ      = baseZ + i * heightFl;
                IDFFile.XYZList floorPoints = new IDFFile.XYZList(groundPoints).ChangeZValue(floorZ);
                IDFFile.Zone    zone        = new IDFFile.Zone(bui, "Zone_" + i, i);
                zone.name = "Zone_" + i;
                IDFFile.People newpeople = new IDFFile.People(10);
                zone.people = newpeople;
                if (i == 0)
                {
                    IDFFile.BuildingSurface floor = new IDFFile.BuildingSurface(zone, floorPoints, area, IDFFile.SurfaceType.Floor);
                }
                else
                {
                    IDFFile.BuildingSurface floor = new IDFFile.BuildingSurface(zone, floorPoints, area, IDFFile.SurfaceType.Floor)
                    {
                        ConstructionName = "General_Floor_Ceiling",
                        OutsideCondition = "Zone", OutsideObject = "Zone_" + (i - 1).ToString()
                    };
                }
                floorPoints.createWalls(zone, heightFl);
                if (i == nFloors - 1)
                {
                    roofPoints.Reverse();
                    IDFFile.BuildingSurface roof = new IDFFile.BuildingSurface(zone, new IDFFile.XYZList(roofPoints), area, IDFFile.SurfaceType.Roof);
                }

                IDFFile.DayLighting DayPoints = new IDFFile.DayLighting(zone, Schedule, dlPoints.ChangeZValue(floorZ + 0.9).xyzs, 500);

                bui.AddZone(zone);
                zoneList.listZones.Add(zone);
            }
            bui.AddZoneList(zoneList);
            bui.CreateShadingControls();
            bui.GeneratePeopleLightingElectricEquipment();
            bui.GenerateInfiltraitionAndVentillation();
            bui.GenerateHVAC(true, false, false);
            return(bui);
        }