public static BHE.OpeningType FromTASOpeningType(this TBD.BuildingElementType tbdType) { switch (tbdType) { case TBD.BuildingElementType.ROOFLIGHT: return(BHE.OpeningType.Rooflight); case TBD.BuildingElementType.DOORELEMENT: return(BHE.OpeningType.Door); case TBD.BuildingElementType.VEHICLEDOOR: return(BHE.OpeningType.VehicleDoor); case TBD.BuildingElementType.GLAZING: return(BHE.OpeningType.Glazing); case TBD.BuildingElementType.CURTAINWALL: return(BHE.OpeningType.CurtainWall); case TBD.BuildingElementType.FRAMEELEMENT: return(BHE.OpeningType.Frame); case TBD.BuildingElementType.NOBETYPE: case TBD.BuildingElementType.NULLELEMENT: return(BHE.OpeningType.Hole); default: return(BHE.OpeningType.Window); } }
public static TBD.BuildingElementType ToTASBuildingElementType(this BHE.Panel element, List <List <BHE.Panel> > spaces = null) { TBD.BuildingElementType tbdType = TBD.BuildingElementType.NULLELEMENT; if (element == null) { return(tbdType); } if (spaces == null) { spaces = new List <List <BHE.Panel> >(); } int adjacentSpaces = element.AdjacentSpaces(spaces).Count; if (adjacentSpaces == 0) { tbdType = TBD.BuildingElementType.SHADEELEMENT; } else { tbdType = TBD.BuildingElementType.NULLELEMENT; } return(tbdType); }
public static BHE.PanelType FromTAS(this TBD.BuildingElementType tbdType) { switch (tbdType) { case TBD.BuildingElementType.EXTERNALWALL: return(BHE.PanelType.WallExternal); case TBD.BuildingElementType.INTERNALWALL: return(BHE.PanelType.WallInternal); case TBD.BuildingElementType.UNDERGROUNDWALL: return(BHE.PanelType.UndergroundWall); case TBD.BuildingElementType.ROOFELEMENT: return(BHE.PanelType.Roof); case TBD.BuildingElementType.CEILING: return(BHE.PanelType.Ceiling); case TBD.BuildingElementType.UNDERGROUNDCEILING: return(BHE.PanelType.UndergroundCeiling); case TBD.BuildingElementType.EXPOSEDFLOOR: return(BHE.PanelType.FloorExposed); case TBD.BuildingElementType.INTERNALFLOOR: return(BHE.PanelType.FloorInternal); case TBD.BuildingElementType.RAISEDFLOOR: return(BHE.PanelType.FloorRaised); case TBD.BuildingElementType.SLABONGRADE: return(BHE.PanelType.SlabOnGrade); case TBD.BuildingElementType.UNDERGROUNDSLAB: return(BHE.PanelType.UndergroundSlab); case TBD.BuildingElementType.CURTAINWALL: return(BHE.PanelType.CurtainWall); case TBD.BuildingElementType.NOBETYPE: case TBD.BuildingElementType.NULLELEMENT: return(BHE.PanelType.Air); case TBD.BuildingElementType.SHADEELEMENT: return(BHE.PanelType.Shade); case TBD.BuildingElementType.SOLARPANEL: return(BHE.PanelType.SolarPanel); default: return(BHE.PanelType.Wall); } }
/***************************************************/ public static bool ElementIsOpening(this TBD.BuildingElementType tbdType) { switch (tbdType) { case TBD.BuildingElementType.ROOFLIGHT: case TBD.BuildingElementType.DOORELEMENT: case TBD.BuildingElementType.VEHICLEDOOR: case TBD.BuildingElementType.GLAZING: case TBD.BuildingElementType.CURTAINWALL: case TBD.BuildingElementType.FRAMEELEMENT: return(true); case TBD.BuildingElementType.NOBETYPE: case TBD.BuildingElementType.NULLELEMENT: return(false); default: return(false); } }
public static List <Guid> AssignBuildingElementType(this string path_TBD, TBD.BuildingElementType buildingElementType, IEnumerable <string> names, bool caseSensitive = true, bool trim = false) { if (string.IsNullOrWhiteSpace(path_TBD)) { return(null); } List <Guid> result = null; using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path_TBD)) { result = AssignBuildingElementType(sAMTBDDocument, buildingElementType, names, caseSensitive, trim); if (result != null) { sAMTBDDocument.Save(); } } return(result); }
public static List <Guid> AssignBuildingElementType(this TBD.Building building, TBD.BuildingElementType buildingElementType, IEnumerable <string> names, bool caseSensitive = true, bool trim = false) { if (building == null || names == null) { return(null); } List <Guid> result = new List <Guid>(); if (names.Count() == 0) { return(result); } List <TBD.buildingElement> buildingElements = building.BuildingElements(); if (buildingElements == null || buildingElements.Count == 0) { return(result); } List <string> names_Temp = new List <string>(names); names_Temp.RemoveAll(x => string.IsNullOrEmpty(x)); if (trim) { names_Temp = names_Temp.ConvertAll(x => x.Trim()); } if (!caseSensitive) { names_Temp = names_Temp.ConvertAll(x => x.ToUpper()); } foreach (TBD.buildingElement buildingElement in buildingElements) { string name = buildingElement?.name; if (string.IsNullOrEmpty(name)) { continue; } if (trim) { name = name.Trim(); } if (!caseSensitive) { name = name.ToUpper(); } if (!names_Temp.Contains(name)) { continue; } buildingElement.BEType = (int)buildingElementType; result.Add(Guid.Parse(buildingElement.GUID)); } return(result); }
public static List <Guid> AssignBuildingElementType(this TBD.TBDDocument tBDDocument, TBD.BuildingElementType buildingElementType, IEnumerable <string> names, bool caseSensitive = true, bool trim = false) { return(AssignBuildingElementType(tBDDocument?.Building, buildingElementType, names, caseSensitive, trim)); }
public static List <Guid> AssignBuildingElementType(this SAMTBDDocument sAMTBDDocument, TBD.BuildingElementType buildingElementType, IEnumerable <string> names, bool caseSensitive = true, bool trim = false) { if (sAMTBDDocument == null) { return(null); } return(AssignBuildingElementType(sAMTBDDocument.TBDDocument, buildingElementType, names, caseSensitive, trim)); }
public static BHE.Panel FromTAS(this TBD.buildingElement tbdElement, TBD.zoneSurface tbdSurface, TASSettings tasSettings) { BHE.Panel element = new BHE.Panel(); TBD.BuildingElementType tbdElementType = ((TBD.BuildingElementType)tbdElement.BEType); TASPanelData tasData = new TASPanelData(); tasData.PanelIsOpening = tbdElementType.ElementIsOpening(); //Add a flag on the element for the final read if (tbdElementType.ElementIsOpening()) { //Find out what the fix was - frame or pane? BHE.OpeningType fixedOpeningType = tbdElementType.FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface); tasData.OpeningIsFrame = fixedOpeningType.OpeningIsFrame(); } BHE.PanelType elementType = ((TBD.BuildingElementType)tbdElement.BEType).FromTAS(); BHPC.Construction elementConstruction = tbdElement.GetConstruction().FromTAS(); element.Name = tbdElement.name; element.Type = elementType; element.Construction = elementConstruction; element.Fragments.Add(tasData); //EnvironmentContextProperties BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment(); environmentContextProperties.ElementID = tbdSurface.GUID.RemoveBrackets(); environmentContextProperties.Description = tbdElement.description; environmentContextProperties.TypeName = tbdSurface.buildingElement.name; element.Fragments.Add(environmentContextProperties); //BuildingElementContextProperties BHP.PanelContextFragment buildingElementContextProperties = new BHP.PanelContextFragment(); element.ConnectedSpaces.Add(tbdSurface.zone.name); if ((int)tbdSurface.type == 3) { element.ConnectedSpaces.Add(tbdSurface.linkSurface.zone.name); } else { element.ConnectedSpaces.Add("-1"); } buildingElementContextProperties.IsAir = tbdElement.ghost != 0; buildingElementContextProperties.IsGround = tbdElement.ground != 0; buildingElementContextProperties.Colour = BH.Engine.Adapters.TAS.Query.GetRGB(tbdElement.colour).ToString(); buildingElementContextProperties.Reversed = tbdSurface.reversed != 0; element.Fragments.Add(buildingElementContextProperties); //BuildingElementAnalyticalProperties BHP.PanelAnalyticalFragment buildingElementAnalyticalProperties = new BHP.PanelAnalyticalFragment(); buildingElementAnalyticalProperties.Altitude = tbdSurface.altitude.Round(); buildingElementAnalyticalProperties.AltitudeRange = tbdSurface.altitudeRange.Round(); buildingElementAnalyticalProperties.Inclination = tbdSurface.inclination.Round(); buildingElementAnalyticalProperties.Orientation = tbdSurface.orientation.Round(); buildingElementAnalyticalProperties.GValue = tbdElement.GValue().Round(); buildingElementAnalyticalProperties.LTValue = tbdElement.LTValue().Round(); buildingElementAnalyticalProperties.UValue = tbdElement.UValue().Round(); element.Fragments.Add(buildingElementAnalyticalProperties); List <BHG.Polyline> panelCurve = new List <BHG.Polyline>(); int surfaceIndex = 0; TBD.RoomSurface roomSurface = null; while ((roomSurface = tbdSurface.GetRoomSurface(surfaceIndex)) != null) { TBD.Perimeter tbdPerimeter = roomSurface.GetPerimeter(); if (tbdPerimeter != null) { panelCurve.Add(tbdPerimeter.FromTAS()); //Add openings int openingIndex = 0; TBD.Polygon openingPolygon = null; while ((openingPolygon = tbdPerimeter.GetHole(openingIndex)) != null) { element.Openings.Add(openingPolygon.FromTASOpening(roomSurface, tasSettings)); openingIndex++; } } surfaceIndex++; } if (panelCurve.Count == 1) { element.ExternalEdges = panelCurve.First().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } else { try { List <BHG.Polyline> polylines = Geometry.Compute.BooleanUnion(panelCurve, 1e-3); if (polylines.Count == 1) { element.ExternalEdges = polylines.First().CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } else { element.ExternalEdges = Geometry.Create.PolyCurve(polylines).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } } catch (Exception e) { BH.Engine.Base.Compute.RecordWarning("An error occurred in building buildingElement ID - " + element.BHoM_Guid + " - error was: " + e.ToString()); element.ExternalEdges = Geometry.Create.PolyCurve(panelCurve).ICollapseToPolyline(BH.oM.Geometry.Tolerance.Angle).CleanPolyline(tasSettings.AngleTolerance, tasSettings.MinimumSegmentLength).ToEdges(); } } tasData.TASID = tbdSurface.GUID.RemoveBrackets(); tasData.TASName = "Z_" + tbdSurface.zone.number + "_" + tbdSurface.number + "_" + tbdSurface.zone.name; tasData.Type = System.Convert.ToString(tbdSurface.type); tasData.Area = tbdSurface.area.Round(); tasData.InternalArea = tbdSurface.internalArea.Round(); tasData.Width = tbdElement.width.Round(); tasData.MaterialLayersThickness = tbdElement.GetConstruction().ConstructionThickness().Round(); element.Fragments.Add(tasData); //AddingExtended Properties for a frame BHE.OpeningType elementOpeningType = tbdElementType.FromTASOpeningType().FixBuildingElementType(tbdElement, tbdSurface); if (elementOpeningType == BHE.OpeningType.RooflightWithFrame || elementOpeningType == BHE.OpeningType.WindowWithFrame) { if (element.Openings.FirstOrDefault() != null) { element.Openings[0].FrameConstruction = elementConstruction; } } return(element); }