public static TBD.InternalCondition AddInternalCondition_HDD(this TBD.Building building, Space space, ProfileLibrary profileLibrary) { if (building == null || space == null || profileLibrary == null) { return(null); } TBD.InternalCondition internalCondition = building.AddIC(null); if (internalCondition == null) { return(null); } List <TBD.dayType> dayTypes = building.DayTypes(); if (dayTypes != null) { dayTypes.RemoveAll(x => !x.name.Equals("HDD")); foreach (TBD.dayType dayType in dayTypes) { internalCondition.SetDayType(dayType, true); } } UpdateInternalCondition_HDD(internalCondition, space, profileLibrary); return(internalCondition); }
public static List <Guid> AddDesignDays(this TBD.Building building, IEnumerable <DesignDay> coolingDesignDays, IEnumerable <DesignDay> heatingDesignDays, int repetitions = 30) { if (building == null) { return(null); } building.ClearDesignDays(); List <TBD.dayType> dayTypes = building.DayTypes(); List <Guid> result = new List <Guid>(); if (coolingDesignDays != null && coolingDesignDays.Count() != 0) { TBD.dayType dayType = dayTypes?.Find(x => x.name == "CDD"); List <TBD.CoolingDesignDay> coolingDesignDays_TBD = building.CoolingDesignDays(); foreach (DesignDay designDay in coolingDesignDays) { if (designDay == null) { continue; } TBD.CoolingDesignDay coolingDesignDay_TBD = coolingDesignDays_TBD?.Find(x => x.name == designDay.Name); if (coolingDesignDay_TBD == null) { coolingDesignDay_TBD = building.AddCoolingDesignDay(); } coolingDesignDay_TBD.Update(designDay, dayType, repetitions); result.Add(Guid.Parse(coolingDesignDay_TBD.GUID)); } } if (heatingDesignDays != null && heatingDesignDays.Count() != 0) { TBD.dayType dayType = dayTypes?.Find(x => x.name == "HDD"); List <TBD.HeatingDesignDay> heatingDesignDays_TBD = building.HeatingDesignDays(); foreach (DesignDay designDay in heatingDesignDays) { if (designDay == null) { continue; } TBD.HeatingDesignDay heatingDesignDay_TBD = heatingDesignDays_TBD?.Find(x => x.name == designDay.Name); if (heatingDesignDay_TBD == null) { heatingDesignDay_TBD = building.AddHeatingDesignDay(); } heatingDesignDay_TBD.Update(designDay, dayType, repetitions); result.Add(Guid.Parse(heatingDesignDay_TBD.GUID)); } } return(result); }
public static TBD.schedule Schedule(this TBD.Building building, string name, IEnumerable <int> values = null) { if (building == null || string.IsNullOrEmpty(name)) { return(null); } TBD.schedule result = building.AddSchedule(); if (result == null) { return(null); } result.name = name; if (values == null) { return(result); } int count = System.Math.Min(24, values.Count()); for (int i = 0; i < count; i++) { result.values[i] = values.ElementAt(i); } return(result); }
public static List <Profile> ToSAM_Profiles(this TBD.Building building) { List <TBD.InternalCondition> internalConditions_TBD = building?.InternalConditions(); if (internalConditions_TBD == null || internalConditions_TBD.Count == 0) { return(null); } List <Profile> result = new List <Profile>(); foreach (TBD.InternalCondition internalCondition_TBD in internalConditions_TBD) { List <Profile> profiles = internalCondition_TBD?.ToSAM_Profiles(); if (profiles == null || profiles.Count == 0) { continue; } profiles.ForEach(x => result.Add(x)); } return(result); }
/***************************************************/ /* * private List<BHS.Elements.Storey> readStorey(List<string> ids = null) * { * TBD.BuildingStorey tbdStorey = m_TBDDocumentInstance.Building.GetStorey(0); * List<BHS.Elements.Storey> storey = new List<BHS.Elements.Storey>(); * storey.Add(Engine.TAS.Convert.ToBHoM(tbdStorey)); * * return storey; * } * * /***************************************************/ private List <Layer> ReadMaterials(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Layer> material = new List <Layer>(); int constructionIndex = 0; while (building.GetConstruction(constructionIndex) != null) { TBD.Construction currConstruction = building.GetConstruction(constructionIndex); int materialIndex = 1; //TAS does not have any material at index 0 while (building.GetConstruction(constructionIndex).materials(materialIndex) != null) { TBD.material tbdMaterial = building.GetConstruction(constructionIndex).materials(materialIndex); material.Add(BH.Engine.Adapters.TAS.Convert.FromTAS(tbdMaterial, currConstruction)); materialIndex++; } constructionIndex++; } return(material); }
/***************************************************/ private List <Building> ReadBuilding(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Building> buildings = new List <Building>(); buildings.Add(BH.Engine.Adapters.TAS.Convert.FromTAS(building)); return(buildings); }
/***************************************************/ private List <BH.oM.Spatial.SettingOut.Level> ReadLevels(List <string> ids = null) { TBD.Building tbdBuilding = m_tbdDocument.Building; List <BH.oM.Spatial.SettingOut.Level> levels = new List <BH.oM.Spatial.SettingOut.Level>(); levels = BH.Engine.Adapters.TAS.Convert.FromTASLevels(tbdBuilding); return(levels); }
public static bool UpdateWeatherData(this TBD.Building building, WeatherData weatherData) { if (building == null || weatherData == null) { return(false); } TBD.WeatherYear weatherYear_TBD = building.GetWeatherYear(); if (weatherYear_TBD == null) { weatherYear_TBD = building.AddWeatherYear(); } building.latitude = System.Convert.ToSingle(weatherData.Latitude); building.longitude = System.Convert.ToSingle(weatherData.Longitude); building.maxBuildingAltitude = System.Convert.ToSingle(weatherData.Elevtion); if (weatherData.TryGetValue(WeatherDataParameter.TimeZone, out string timeZone)) { double @double = Core.Query.Double(Core.Query.UTC(timeZone)); if (!double.IsNaN(@double)) { building.timeZone = System.Convert.ToSingle(@double); } } weatherYear_TBD.latitude = building.latitude; weatherYear_TBD.longitude = building.longitude; weatherYear_TBD.name = weatherData.Name; weatherYear_TBD.description = weatherData.Description; weatherYear_TBD.altitude = System.Convert.ToSingle(weatherData.Elevtion); weatherYear_TBD.timeZone = building.timeZone; if (weatherData.TryGetValue(WeatherDataParameter.GroundTemperatures, out Core.SAMCollection <GroundTemperature> groundTemperatures) && groundTemperatures != null && groundTemperatures.Count != 0) { GroundTemperature groundTemperature = groundTemperatures.ToList().Find(x => System.Math.Abs(x.Depth - 2.0) < Core.Tolerance.MacroDistance); if (groundTemperature == null) { groundTemperature = groundTemperatures.FirstOrDefault(); } if (groundTemperature != null) { weatherYear_TBD.groundTemperature = System.Convert.ToSingle(groundTemperature.Temperatures.Sum() / 12.0); } } WeatherYear weatherYear = weatherData.WeatherYears?.FirstOrDefault(); if (weatherYear != null) { weatherYear_TBD.year = weatherYear.Year; } return(Update(weatherYear_TBD, weatherYear)); }
public static bool RemoveInternalCondition(this TBD.Building building, string name) { if (string.IsNullOrWhiteSpace(name)) { return(false); } List <bool> result = RemoveInternalConditions(building, new string[] { name }); return(result != null && result.Count > 0 && result[0]); }
public static bool UpdateZones(this TBD.Building building, AnalyticalModel analyticalModel, bool includeHDD = false) { if (analyticalModel == null || building == null) { return(false); } building.name = analyticalModel.Name; return(UpdateZones(building, analyticalModel?.AdjacencyCluster, analyticalModel.ProfileLibrary, includeHDD)); }
public static TBD.Construction Construction(this TBD.Building building, string name, bool caseSesitive = true, bool trim = false) { if (building == null || string.IsNullOrWhiteSpace(name)) { return(null); } string name_Temp = name; if (trim) { name_Temp = name_Temp.Trim(); } if (!caseSesitive) { name_Temp = name_Temp.ToUpper(); } int index = 0; TBD.Construction construction = building.GetConstruction(index); while (construction != null) { string name_Construction = construction.name; if (string.IsNullOrWhiteSpace(name_Construction)) { continue; } if (trim) { name_Construction = name_Construction.Trim(); } if (!caseSesitive) { name_Construction = name_Construction.ToUpper(); } if (name_Construction.Equals(name_Temp)) { return(construction); } index++; construction = building.GetConstruction(index); } return(null); }
private static List <TBD.dayType> DayTypes(this TBD.Building building, int start = 0, int end = 365) { List <TBD.dayType> result = new List <TBD.dayType>(); TBD.Calendar calendar = building.GetCalendar(); for (int i = start; i < end; i++) { result.Add(calendar.days(i + 1).dayType); } return(result); }
public static List <bool> UpdateSurfaceOutputSpecs(this TBD.TBDDocument tBDDocument, IEnumerable <SurfaceOutputSpec> surfaceOutputSpecs) { if (tBDDocument == null || surfaceOutputSpecs == null) { return(null); } TBD.Building building = tBDDocument.Building; if (building == null) { return(null); } List <bool> result = new List <bool>(); List <TBD.SurfaceOutputSpec> surfaceOutputSpecs_TBD = building?.SurfaceOutputSpecs(); foreach (TBD.SurfaceOutputSpec surfaceOutputSpec_TBD in surfaceOutputSpecs_TBD) { tBDDocument.DeleteObjectByName(surfaceOutputSpec_TBD.name); } surfaceOutputSpecs_TBD.Clear(); foreach (SurfaceOutputSpec surfaceOutputSpec in surfaceOutputSpecs) { if (surfaceOutputSpec == null) { continue; } TBD.SurfaceOutputSpec surfaceOutputSpec_TBD = surfaceOutputSpecs_TBD.Find(x => x.name == surfaceOutputSpec.Name); if (surfaceOutputSpec_TBD == null) { surfaceOutputSpec_TBD = building.AddSurfaceOutputSpec(); if (surfaceOutputSpec.Name != null) { surfaceOutputSpec_TBD.name = surfaceOutputSpec.Name; } } surfaceOutputSpec_TBD.description = surfaceOutputSpec.Description; surfaceOutputSpec_TBD.apertureData = surfaceOutputSpec.ApertureData ? 1 : 0; surfaceOutputSpec_TBD.condensation = surfaceOutputSpec.Condensation ? 1 : 0; surfaceOutputSpec_TBD.convection = surfaceOutputSpec.Convection ? 1 : 0; surfaceOutputSpec_TBD.solarGain = surfaceOutputSpec.SolarGain ? 1 : 0; surfaceOutputSpec_TBD.conduction = surfaceOutputSpec.Conduction ? 1 : 0; surfaceOutputSpec_TBD.longWave = surfaceOutputSpec.LongWave ? 1 : 0; surfaceOutputSpec_TBD.dryBulbTemp = surfaceOutputSpec.Temperature ? 1 : 0; } return(result); }
public static TBD.buildingElement BuildingElement(TBD.Building tbdBuilding, BH.oM.Geometry.ICurve panelCurve) { /*int index = 0; * TBD.buildingElement tbdBuildingElement = null; * while ((tbdBuildingElement = tbdBuilding.GetBuildingElement(index)) != null) * { * if (tbdBuildingElement. == panelCurve) * return tbdBuildingElement; * index++; * }*/ return(null); }
public static BHE.Building FromTAS(this TBD.Building tbdBuilding) { BHE.Building building = new BHE.Building(); building.Name = tbdBuilding.name; building.Location.Latitude = tbdBuilding.latitude; building.Location.Longitude = tbdBuilding.longitude; building.Elevation = tbdBuilding.maxBuildingAltitude; //building.Elevation = tbdBuilding.GetWeatherYear().altitude; //Consider switching to this if maxBuildingAltitude does not work //EnvironmentContextProperties BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment(); environmentContextProperties.ElementID = tbdBuilding.GUID.RemoveBrackets(); environmentContextProperties.Description = tbdBuilding.description; environmentContextProperties.TypeName = tbdBuilding.name; building.Fragments.Add(environmentContextProperties); //BuildingAnalyticalProperties BHP.BuildingAnalyticalFragment buildingAnalyticalProperties = new BHP.BuildingAnalyticalFragment(); buildingAnalyticalProperties.NorthAngle = tbdBuilding.northAngle; //North Angle (degrees) Measured clockwise with respect to the Y - axis of the building plan. buildingAnalyticalProperties.Year = tbdBuilding.year; buildingAnalyticalProperties.GMTOffset = tbdBuilding.timeZone; building.Fragments.Add(buildingAnalyticalProperties); //BuildingContextProperties TBD.WeatherYear weatherYear = tbdBuilding.GetWeatherYear(); if (weatherYear != null) { BHP.BuildingContextFragment buildingContextProperties = new BHP.BuildingContextFragment(); buildingContextProperties.PlaceName = weatherYear.name; buildingContextProperties.WeatherStation = weatherYear.description; building.Fragments.Add(buildingContextProperties); } //BuildingResultsProperties BHP.BuildingResultFragment buildingResultsProperties = new BHP.BuildingResultFragment(); buildingResultsProperties.PeakCooling = tbdBuilding.peakCooling; buildingResultsProperties.PeakHeating = tbdBuilding.peakHeating; building.Fragments.Add(buildingResultsProperties); //Extended Properties TASBuilding tasData = new TASBuilding(); tasData.ID = tbdBuilding.GUID.RemoveBrackets(); tasData.TASID = tbdBuilding.TBDGUID; tasData.PathFile = tbdBuilding.path3DFile; building.Fragments.Add(tasData); return(building); }
public static WeatherData ToSAM_WeatherData(this TBD.Building building) { if (building == null) { return(null); } TBD.WeatherYear weatherYear_TBD = building.GetWeatherYear(); if (weatherYear_TBD == null) { return(null); } return(ToSAM_WeatherData(weatherYear_TBD)); }
public static List <BHS.Level> FromTASLevels(this TBD.Building tbdBuilding) { List <BHS.Level> levels = new List <BHS.Level>(); int storeyIndex = 0; TBD.BuildingStorey storey = null; while ((storey = tbdBuilding.GetStorey(storeyIndex)) != null) { levels.Add(storey.FromTAS()); storeyIndex++; } return(levels); }
public static ProfileLibrary ToSAM_ProfileLibrary(this TBD.Building building) { List <Profile> profiles = building?.ToSAM_Profiles(); if (profiles == null) { return(null); } ProfileLibrary result = new ProfileLibrary(building.name); profiles.ForEach(x => result.Add(x)); return(result); }
public static TBD.buildingElement BuildingElement(TBD.Building tbdBuilding, string name) { int index = 0; TBD.buildingElement tbdBuildingElement = null; while ((tbdBuildingElement = tbdBuilding.GetBuildingElement(index)) != null) { if (tbdBuildingElement.name == name) { return(tbdBuildingElement); } index++; } return(null); }
/***************************************************/ public List <Construction> ReadConstruction(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Construction> constructions = new List <Construction>(); int buildingElementIndex = 0; while (building.GetConstruction(buildingElementIndex) != null) { TBD.Construction construction = m_tbdDocument.Building.GetConstruction(buildingElementIndex); constructions.Add(BH.Engine.Adapters.TAS.Convert.FromTAS(construction)); //ToDo: FIX THIS buildingElementIndex++; } return(constructions); }
public static bool RemoveApertureTypes(this TBD.Building building) { if (building == null) { return(false); } TBD.ApertureType apertureType = building.GetApertureType(0); while (apertureType != null) { building.RemoveApertureType(0); apertureType = building.GetApertureType(0); } return(true); }
public static bool RemoveIZAMs(this TBD.Building building) { if (building == null) { return(false); } TBD.IZAM iZAM = building.GetIZAM(0); while (iZAM != null) { building.RemoveIZAM(0); iZAM = building.GetIZAM(0); } return(true); }
public static Core.MaterialLibrary ToSAM_MaterialLibrary(this TBD.Building building) { List <TBD.Construction> constructions = building?.Constructions(); if (constructions == null) { return(null); } Core.MaterialLibrary result = new Core.MaterialLibrary(building.name); foreach (TBD.Construction construction in constructions) { if (construction == null) { continue; } List <TBD.material> materials_TBD = construction.Materials(); if (materials_TBD == null || materials_TBD.Count == 0) { continue; } foreach (TBD.material material_TBD in materials_TBD) { if (material_TBD == null) { continue; } if (result.GetMaterial(material_TBD.name) != null) { continue; } Core.IMaterial material = material_TBD.ToSAM(); if (material == null) { continue; } result.Add(material); } } return(result); }
public static List <TBD.SurfaceOutputSpec> SurfaceOutputSpecs(this TBD.Building building) { List <TBD.SurfaceOutputSpec> result = new List <TBD.SurfaceOutputSpec>(); int index = 0; TBD.SurfaceOutputSpec surfaceOutputSpec = building.GetSurfaceOutputSpec(index); while (surfaceOutputSpec != null) { result.Add(surfaceOutputSpec); index++; surfaceOutputSpec = building.GetSurfaceOutputSpec(index); } return(result); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private List <Space> ReadSpaces(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Space> spaces = new List <Space>(); int zoneIndex = 0; while (building.GetZone(zoneIndex) != null) { TBD.zone zone = m_tbdDocument.Building.GetZone(zoneIndex); spaces.Add(BH.Engine.Adapters.TAS.Convert.FromTAS(zone, m_tbdDocument)); zoneIndex++; } return(spaces); }
public static List <TBD.buildingElement> BuildingElements(this TBD.Building building) { List <TBD.buildingElement> result = new List <TBD.buildingElement>(); int index = 0; TBD.buildingElement buildingElement = building.GetBuildingElement(index); while (buildingElement != null) { result.Add(buildingElement); index++; buildingElement = building.GetBuildingElement(index); } return(result); }
public static List <TBD.schedule> Schedules(this TBD.Building building) { List <TBD.schedule> result = new List <TBD.schedule>(); int index = 0; TBD.schedule schedule = building.GetSchedule(index); while (schedule != null) { result.Add(schedule); index++; schedule = building.GetSchedule(index); } return(result); }
public static TBD.Building ToTAS(this BHE.Building building, TBD.Building tbdBuilding) { //TODO:Add BuildingHeightAdjustmentFactor, MeanHeightOfSurroundings, TerrainType, NumberOfPreconditioningDays, GroundSolarReflectance, ExternalPollutant //TODO:Check if Longitude, Latitude, NorthAngle, Timezone, Path3Dfile, BuildingYear is pushed if (building == null) { return(tbdBuilding); } tbdBuilding.name = building.Name; tbdBuilding.latitude = (float)building.Location.Latitude; tbdBuilding.longitude = (float)building.Location.Longitude; tbdBuilding.maxBuildingAltitude = (float)building.Elevation; TASBuilding tasFragment = building.FindFragment <TASBuilding>(typeof(TASBuilding)); if (tasFragment != null) { tbdBuilding.GUID = tasFragment.ID; tbdBuilding.TBDGUID = tasFragment.TASID; tbdBuilding.path3DFile = tasFragment.PathFile; } BHP.OriginContextFragment environmentContextFragment = new BHP.OriginContextFragment(); if (environmentContextFragment != null) { tbdBuilding.description = environmentContextFragment.Description; } BHP.BuildingResultFragment buildingResultsFragment = building.FindFragment <BHP.BuildingResultFragment>(typeof(BHP.BuildingResultFragment)); if (buildingResultsFragment != null) { tbdBuilding.peakCooling = (float)System.Convert.ToDouble(buildingResultsFragment.PeakCooling); tbdBuilding.peakHeating = (float)System.Convert.ToDouble(buildingResultsFragment.PeakHeating); } BHP.BuildingAnalyticalFragment analyticalFragment = building.FindFragment <BHP.BuildingAnalyticalFragment>(typeof(BHP.BuildingAnalyticalFragment)); if (analyticalFragment != null) { tbdBuilding.northAngle = (float)System.Convert.ToDouble(analyticalFragment.NorthAngle); tbdBuilding.timeZone = (float)System.Convert.ToDouble(analyticalFragment.GMTOffset); } return(tbdBuilding); }
public static List <TBD.Construction> Constructions(this TBD.Building building) { List <TBD.Construction> result = new List <TBD.Construction>(); int index = 0; TBD.Construction construction = building.GetConstruction(index); while (construction != null) { result.Add(construction); index++; construction = building.GetConstruction(index); } return(result); }
public static List <TBD.HeatingDesignDay> HeatingDesignDays(this TBD.Building building) { List <TBD.HeatingDesignDay> result = new List <TBD.HeatingDesignDay>(); int index = 0; TBD.HeatingDesignDay heatingDesignDay = building?.GetHeatingDesignDay(index); while (heatingDesignDay != null) { result.Add(heatingDesignDay); index++; heatingDesignDay = building?.GetHeatingDesignDay(index); } return(result); }