public static WindowConstructionAbridged ToLadybugTools_WindowConstructionAbridged(this WindowType windowType, bool reverse = true) { if (windowType == null) { return(null); } List <Architectural.MaterialLayer> materialLayers = windowType.PaneMaterialLayers; if (materialLayers == null) { return(null); } if (reverse) { materialLayers.Reverse(); } WindowConstructionAbridged result = new WindowConstructionAbridged( identifier: Query.UniqueName(windowType, reverse), materials: materialLayers.ConvertAll(x => x.Name), displayName: windowType.Name); return(result); }
public static WindowConstructionAbridged ToLadybugTools_WindowConstructionAbridged(this ApertureConstruction apertureConstruction, bool reverse = true) { if (apertureConstruction == null) { return(null); } List <ConstructionLayer> constructionLayers = apertureConstruction.PaneConstructionLayers; if (constructionLayers == null) { return(null); } if (reverse) { constructionLayers.Reverse(); } WindowConstructionAbridged result = new WindowConstructionAbridged( identifier: Query.UniqueName(apertureConstruction, reverse), materials: constructionLayers.ConvertAll(x => x.Name), displayName: apertureConstruction.Name); return(result); }
public static AnyOf <Ground, Outdoors, Adiabatic, Surface> ToLadybugTools_BoundaryCondition(this IPartition partition, BuildingModel buildingModel, Space space) { if (partition == null || buildingModel == null) { return(null); } if (partition is IHostPartition) { if (((IHostPartition)partition).Adiabatic()) { return(new Adiabatic()); } } if (buildingModel.External(partition)) { return(new Outdoors()); } if (buildingModel.Underground(partition)) { if (!buildingModel.Internal(partition)) { return(new Ground()); } } int index_Adjacent = -1; List <Space> spaces = null; if (partition != null) { spaces = buildingModel.GetSpaces(partition); if (spaces != null && spaces.Count != 0) { index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid); index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]); } } if (index_Adjacent == -1) { return(null); } //boundaryConditionObjects have to be provided //https://www.ladybug.tools/honeybee-schema/model.html#tag/surface_model List <string> uniqueNames = new List <string>(); uniqueNames.Add(Query.UniqueName(partition, index_Adjacent)); uniqueNames.Add(Query.UniqueName(spaces[index_Adjacent])); return(new Surface(uniqueNames)); }
public static Shade ToLadybugTools_Shade(this IPartition partition) { if (partition == null) { return(null); } Face3D face3D = partition.Face3D?.ToLadybugTools(); if (face3D == null) { return(null); } ShadePropertiesAbridged shadePropertiesAbridged = new ShadePropertiesAbridged(); Shade shade = new Shade(Query.UniqueName(partition), face3D, shadePropertiesAbridged, partition.Name); return(shade); }
public static Shade ToLadybugTools_Shade(this Panel panel) { if (panel == null || panel.PanelType != PanelType.Shade) { return(null); } Face3D face3D = panel.GetFace3D(true)?.ToLadybugTools(); if (face3D == null) { return(null); } ShadePropertiesAbridged shadePropertiesAbridged = new ShadePropertiesAbridged(); Shade shade = new Shade(Query.UniqueName(panel), face3D, shadePropertiesAbridged, panel.Name); return(shade); }
public static OpaqueConstructionAbridged ToLadybugTools(this HostPartitionType hostPartitionType, bool reverse = true) { if (hostPartitionType == null) { return(null); } List <Architectural.MaterialLayer> materialLayers = hostPartitionType.MaterialLayers; if (materialLayers == null || materialLayers.Count == 0) { return(null); } if (reverse) { materialLayers.Reverse(); } OpaqueConstructionAbridged result = new OpaqueConstructionAbridged(Query.UniqueName(hostPartitionType, reverse), materialLayers.ConvertAll(x => x.Name), hostPartitionType.Name); return(result); }
public static OpaqueConstructionAbridged ToLadybugTools(this Construction construction, bool reverse = true) { if (construction == null) { return(null); } List <ConstructionLayer> constructionLayers = construction.ConstructionLayers; if (constructionLayers == null || constructionLayers.Count == 0) { return(null); } if (reverse) { constructionLayers.Reverse(); } OpaqueConstructionAbridged result = new OpaqueConstructionAbridged(Query.UniqueName(construction, reverse), constructionLayers.ConvertAll(x => x.Name), construction.Name); return(result); }
public static HoneybeeSchema.Door ToLadybugTools(this IOpening opening, BuildingModel buildingModel, Space space) { if (opening == null || buildingModel == null) { return(null); } OpeningType openingType = opening.Type(); if (openingType == null) { return(null); } //Opaque Windows to be replaced by Doors if (opening is Window && buildingModel.GetMaterialType(openingType.PaneMaterialLayers) != MaterialType.Opaque) { return(null); } IHostPartition hostPartition = buildingModel.GetHostPartition(opening); int index = -1; int index_Adjacent = -1; List <Space> spaces = null; if (hostPartition != null) { spaces = buildingModel.GetSpaces(hostPartition); if (spaces != null && spaces.Count != 0) { index = spaces.FindIndex(x => x.Guid == space.Guid); index = buildingModel.UniqueIndex(spaces[index]); index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid); index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]); } } HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = null; if (index == -1 || index_Adjacent == -1) { anyOf = new Outdoors(); } else { bool reversed = index_Adjacent < index; List <string> uniqueNames = new List <string>(); uniqueNames.Add(Core.LadybugTools.Query.UniqueName(opening as SAMObject, index_Adjacent)); uniqueNames.Add(Query.UniqueName(hostPartition, index_Adjacent)); uniqueNames.Add(Query.UniqueName(spaces[index_Adjacent])); anyOf = new Surface(uniqueNames); } Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(opening); DoorEnergyPropertiesAbridged doorEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(construction: Query.UniqueName(opening.Type(), !(index_Adjacent != -1 && index <= index_Adjacent))); return(new HoneybeeSchema.Door( identifier: Core.LadybugTools.Query.UniqueName(opening as SAMObject, index), geometry: face3D, boundaryCondition: anyOf, properties: new DoorPropertiesAbridged(doorEnergyPropertiesAbridged), displayName: opening.Name)); }
public static Face ToLadybugTools_Face(this Panel panel, AnalyticalModel analyticalModel = null, int index = -1, bool reverse = true) { if (panel == null || panel.PanelType == PanelType.Shade) { return(null); } Face3D face3D = panel.PlanarBoundary3D.ToLadybugTools(); if (face3D == null) { return(null); } AdjacencyCluster adjacencyCluster = analyticalModel?.AdjacencyCluster; Space space_Adjacent = null; int index_Adjacent = -1; if (adjacencyCluster != null && index != -1) { List <Space> spaces = adjacencyCluster.GetSpaces(panel); if (spaces != null && spaces.Count != 0) { foreach (Space space in spaces) { int index_Temp = adjacencyCluster.GetIndex(space); if (!index_Temp.Equals(index)) { space_Adjacent = space; index_Adjacent = index_Temp; break; } } } } string adjacentPanelUniqueName = null; string adjacentSpaceUniqueName = null; if (space_Adjacent != null && index_Adjacent != -1) { adjacentPanelUniqueName = Query.UniqueName(panel, index_Adjacent); adjacentSpaceUniqueName = Query.UniqueName(space_Adjacent); } AnyOf <Ground, Outdoors, Adiabatic, Surface> boundaryCondition = panel.ToLadybugTools_BoundaryCondition(adjacentPanelUniqueName, adjacentSpaceUniqueName); FaceType faceType; PanelType panelType = panel.PanelType; PanelGroup panelGroup = panelType.PanelGroup(); if (panelGroup == PanelGroup.Floor && Analytical.Query.PanelType(panel.Normal) == PanelType.Roof) { faceType = FaceType.RoofCeiling; } else { faceType = Query.FaceTypeEnum(panelType); } FaceEnergyPropertiesAbridged faceEnergyPropertiesAbridged = new FaceEnergyPropertiesAbridged(); if (faceType != FaceType.AirBoundary) { faceEnergyPropertiesAbridged.Construction = Query.UniqueName(panel.Construction, reverse); } Face face = new Face(Query.UniqueName(panel, index), face3D, faceType, boundaryCondition, new FacePropertiesAbridged(faceEnergyPropertiesAbridged), panel.Name); List <Aperture> apertures = panel.Apertures;//Analytical.Query.OffsetAperturesOnEdge(panel, 0.1); if (apertures != null && apertures.Count > 0) { MaterialLibrary materialLibrary = analyticalModel?.MaterialLibrary; face.Apertures = apertures.ConvertAll(x => x.ToLadybugTools(materialLibrary, index, index_Adjacent, adjacentPanelUniqueName, adjacentSpaceUniqueName)).FindAll(x => x != null); face.Doors = apertures.ConvertAll(x => x.ToLadybugTools_Door(materialLibrary, index, index_Adjacent, adjacentPanelUniqueName, adjacentSpaceUniqueName)).FindAll(x => x != null); } return(face); }
public static Face ToLadybugTools_Face(this IPartition partition, BuildingModel buildingModel, Space space) { Face3D face3D = Geometry.LadybugTools.Convert.ToLadybugTools(partition?.Face3D); if (face3D == null) { return(null); } FaceType?faceType = partition.FaceType(); if (faceType == null || !faceType.HasValue) { return(null); } int index = -1; int index_Adjacent = -1; bool reverse = true; List <Space> spaces = buildingModel.GetSpaces(partition); if (spaces != null && spaces.Count != 0) { index = spaces.FindIndex(x => x.Guid == space.Guid); index = buildingModel.UniqueIndex(spaces[index]); index_Adjacent = spaces.FindIndex(x => x.Guid != space.Guid); index_Adjacent = buildingModel.UniqueIndex(spaces[index_Adjacent]); reverse = buildingModel.UniqueIndex(spaces[0]) != index; } AnyOf <Ground, Outdoors, Adiabatic, Surface> boundaryCondition = partition.ToLadybugTools_BoundaryCondition(buildingModel, space); FaceEnergyPropertiesAbridged faceEnergyPropertiesAbridged = new FaceEnergyPropertiesAbridged(); if (partition is IHostPartition) { faceEnergyPropertiesAbridged.Construction = Query.UniqueName(((IHostPartition)partition).Type(), reverse); } Face face = new Face(Query.UniqueName(partition, index), face3D, faceType.Value, boundaryCondition, new FacePropertiesAbridged(faceEnergyPropertiesAbridged), partition.Name); if (partition is IHostPartition) { List <IOpening> openings = ((IHostPartition)partition).GetOpenings(); if (openings != null && openings.Count != 0) { List <HoneybeeSchema.Aperture> apertures = new List <HoneybeeSchema.Aperture>(); List <HoneybeeSchema.Door> doors = new List <HoneybeeSchema.Door>(); foreach (IOpening opening in openings) { MaterialType materialType = MaterialType.Opaque; OpeningType openingType = opening.Type(); if (openingType != null) { materialType = buildingModel.GetMaterialType(openingType.PaneMaterialLayers); } if (opening is Window && materialType != MaterialType.Opaque) { HoneybeeSchema.Aperture aperture = ((Window)opening).ToLadybugTools(buildingModel, space); if (aperture != null) { apertures.Add(aperture); } } else { HoneybeeSchema.Door door = opening.ToLadybugTools(buildingModel, space); if (door != null) { doors.Add(door); } } } if (apertures != null && apertures.Count != 0) { face.Apertures = apertures; } if (doors != null && doors.Count != 0) { face.Doors = doors; } } } return(face); }
public static HoneybeeSchema.Door ToLadybugTools_Door(this Aperture aperture, MaterialLibrary materialLibrary = null, int index = -1, int index_Adjacent = -1, string adjacentPanelUniqueName = null, string adjacentSpaceUniqueName = null) { if (aperture == null) { return(null); } ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction == null) { return(null); } MaterialType materialType = apertureConstruction.PaneConstructionLayers.MaterialType(materialLibrary); if (aperture.ApertureType != ApertureType.Door) { //Opaque Windows to be replaced by Doors if (materialType != MaterialType.Opaque) { return(null); } } PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D; if (planarBoundary3D == null) { return(null); } HoneybeeSchema.AnyOf <Outdoors, Surface> anyOf = new Outdoors(); Face3D face3D = planarBoundary3D.ToLadybugTools(); if (!string.IsNullOrEmpty(adjacentPanelUniqueName) && !string.IsNullOrEmpty(adjacentSpaceUniqueName)) { List <string> uniqueNames = new List <string>(); uniqueNames.Add(Core.LadybugTools.Query.UniqueName(aperture, index_Adjacent)); uniqueNames.Add(adjacentPanelUniqueName); uniqueNames.Add(adjacentSpaceUniqueName); anyOf = new Surface(uniqueNames); } DoorEnergyPropertiesAbridged apertureEnergyPropertiesAbridged = new DoorEnergyPropertiesAbridged(Query.UniqueName(apertureConstruction, !(index_Adjacent != -1 && index <= index_Adjacent))); HoneybeeSchema.Door door = new HoneybeeSchema.Door( identifier: Core.LadybugTools.Query.UniqueName(aperture, index), geometry: face3D, boundaryCondition: anyOf, properties: new DoorPropertiesAbridged(apertureEnergyPropertiesAbridged), displayName: aperture.Name); door.IsGlass = materialType == MaterialType.Transparent; return(door); }
public static Room ToLadybugTools(this Space space, AnalyticalModel analyticalModel = null, double silverSpacing = Core.Tolerance.MacroDistance, double tolerance = Core.Tolerance.Distance) { if (space == null) { return(null); } int index = -1; List <Panel> panels = null; AdjacencyCluster adjacencyCluster = analyticalModel?.AdjacencyCluster; if (adjacencyCluster != null) { index = adjacencyCluster.GetIndex(space); panels = adjacencyCluster.UpdateNormals(space, false, silverSpacing, tolerance); } if (panels == null || panels.Count == 0) { return(null); } string uniqueName = Query.UniqueName(space); List <Face> faces = null; if (panels != null) { faces = new List <Face>(); foreach (Panel panel in panels) { if (panel == null) { continue; } bool reverse = true; List <Space> spaces = adjacencyCluster?.GetSpaces(panel); if (spaces != null && spaces.Count > 1) { reverse = adjacencyCluster.GetIndex(spaces[0]) != index; } Face face = panel.ToLadybugTools_Face(analyticalModel, index, reverse); if (face == null) { continue; } faces.Add(face); } } RoomPropertiesAbridged roomPropertiesAbridged = new RoomPropertiesAbridged(); Room result = new Room(uniqueName, faces, roomPropertiesAbridged, space.Name); InternalCondition internalCondition = space.InternalCondition; if (internalCondition != null) { string uniqueName_InternalCondition = Core.LadybugTools.Query.UniqueName(internalCondition); if (!string.IsNullOrWhiteSpace(uniqueName_InternalCondition)) { roomPropertiesAbridged = result.Properties; RoomEnergyPropertiesAbridged roomEnergyPropertiesAbridged = roomPropertiesAbridged.Energy; if (roomEnergyPropertiesAbridged == null) { roomEnergyPropertiesAbridged = new RoomEnergyPropertiesAbridged(programType: uniqueName_InternalCondition); } result.Properties.Energy = roomEnergyPropertiesAbridged; } } return(result); }