public static Face3D ToLadybugTools(this PlanarBoundary3D planarBoundary3D) { if (planarBoundary3D == null) { return(null); } PlanarBoundary3D planarBoundary3D_Temp = new PlanarBoundary3D(planarBoundary3D); planarBoundary3D_Temp.Normalize(); List <List <double> > boundary = ToLadybugTools(planarBoundary3D_Temp.GetExternalEdge3DLoop()); List <BoundaryEdge3DLoop> internalBoundaryEdge3DLoops = planarBoundary3D_Temp.GetInternalEdge3DLoops(); List <List <List <double> > > holes = null; if (internalBoundaryEdge3DLoops != null) { holes = new List <List <List <double> > >(); foreach (BoundaryEdge3DLoop internalBoundaryEdge3DLoop in internalBoundaryEdge3DLoops) { holes.Add(ToLadybugTools(internalBoundaryEdge3DLoop)); } } return(new Face3D(boundary, holes)); }
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 RectangularGeometry TogbXML_RectangularGeometry(this PlanarBoundary3D planarBoundary3D, double tolerance = Core.Tolerance.MicroDistance) { if (planarBoundary3D == null) { return(null); } return(Geometry.gbXML.Convert.TogbXML_RectangularGeometry(planarBoundary3D.GetFace3D(), tolerance)); }
public static Opening TogbXML(this Aperture aperture, int cADObjectIdSufix = -1, double tolerance = Core.Tolerance.MicroDistance) { if (aperture == null) { return(null); } PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D; if (planarBoundary3D == null) { return(null); } ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction == null) { return(null); } string name = aperture.Name; if (string.IsNullOrWhiteSpace(name)) { name = aperture.ApertureConstruction.Name; } Opening opening = new Opening(); //opening.constructionIdRef = Core.gbXML.Query.Id(aperture.ApertureConstruction, typeof(gbXMLSerializer.Construction)); opening.Description = name; opening.id = Core.gbXML.Query.Id(aperture, typeof(Opening)); if (cADObjectIdSufix == -1) { opening.Name = string.Format("{0} [{1}]", name, aperture.Guid); } else { opening.Name = string.Format("{0} [{1}]", name, cADObjectIdSufix); } opening.openingType = Query.OpeningTypeEnum(aperture.ApertureConstruction.ApertureType); opening.pg = planarBoundary3D.TogbXML(tolerance); opening.rg = planarBoundary3D.TogbXML_RectangularGeometry(tolerance); opening.CADObjectId = Query.CADObjectId(aperture, cADObjectIdSufix); return(opening); }
public static shade ToT3D_Shade(this Panel panel, Building building) { if (panel == null) { return(null); } uint colour; if (!Core.Query.TryGetValue(panel, "Colour", out colour)) { colour = Core.Convert.ToUint(System.Drawing.Color.Black); } double width = double.NaN; double height = double.NaN; double level = double.NaN; PlanarBoundary3D planarBoundary3D = panel.PlanarBoundary3D; if (planarBoundary3D != null) { if (!Core.Query.TryGetValue(panel, "Width", out width)) { return(null); } if (!Core.Query.TryGetValue(panel, "Height", out height)) { return(null); } if (!Core.Query.TryGetValue(panel, "Level", out level)) { return(null); } } else { width = planarBoundary3D.Width(); height = planarBoundary3D.Height(); level = Analytical.Query.MinElevation(panel); } shade result = building.AddShade(panel.Name, Query.OpeningType(panel), colour, height, width, level); return(result); }
public static window ToT3D(this Aperture aperture, Building building) { if (aperture == null) { return(null); } uint colour; if (!Core.Query.TryGetValue(aperture, "Colour", out colour)) { colour = Core.Convert.ToUint(Color.Black); } double width = double.NaN; double height = double.NaN; double level = double.NaN; PlanarBoundary3D planarBoundary3D = aperture.PlanarBoundary3D; if (planarBoundary3D == null) { if (!Core.Query.TryGetValue(aperture, "Width", out width)) { return(null); } if (!Core.Query.TryGetValue(aperture, "Height", out height)) { return(null); } if (!Core.Query.TryGetValue(aperture, "Level", out level)) { return(null); } } else { width = planarBoundary3D.Width(); height = planarBoundary3D.Height(); level = Analytical.Query.MinElevation(planarBoundary3D); } window result = building.AddWindow(aperture.Name, Query.OpeningType(aperture), colour, height, width, level); return(result); }
public static Panel ToSAM(this TAS3D.Element element) { if (element == null) { return(null); } ParameterSet parameterSet = Create.ParameterSet(ActiveSetting.Setting, element); PlanarBoundary3D planarBoundary3D = null; Panel panel = Analytical.Create.Panel(new Construction(element.name), Query.PanelType(element.BEType), planarBoundary3D); panel.Add(parameterSet); return(panel); }
public static Panel ToSAM(this TAS3D.shade shade) { if (shade == null) { return(null); } ParameterSet parameterSet = Create.ParameterSet(ActiveSetting.Setting, shade); PlanarBoundary3D planarBoundary3D = null; Panel panel = Analytical.Create.Panel(new Construction(shade.name), PanelType.Shade, planarBoundary3D); panel.Add(parameterSet); return(panel); }
public static PlanarGeometry TogbXML(this PlanarBoundary3D planarBoundary3D, double tolerance = Core.Tolerance.MicroDistance) { if (planarBoundary3D == null) { return(null); } Geometry.Spatial.Face3D face3D = planarBoundary3D.GetFace3D(); if (face3D == null) { return(null); } PlanarGeometry planarGeometry = new PlanarGeometry(); planarGeometry.PolyLoop = face3D.TogbXML_PolyLoop(tolerance); return(planarGeometry); }
public static PlanarBoundary3D Transform(this Transform transform, PlanarBoundary3D planarBoundary3D) { if (transform == null || planarBoundary3D == null) { return(null); } if (transform.IsIdentity) { return(new PlanarBoundary3D(planarBoundary3D)); } Geometry.Spatial.Face3D face3D = planarBoundary3D.GetFace3D(); if (face3D == null || !Geometry.Spatial.Query.IsValid(face3D)) { return(null); } return(new PlanarBoundary3D(Geometry.Revit.Query.Transform(transform, face3D))); }
public static Panel ToSAM(this SurfaceData surfaceData, IEnumerable <PanelDataType> panelDataTypes = null) { if (surfaceData == null) { return(null); } ParameterSet parameterSet = Create.ParameterSet(ActiveSetting.Setting, surfaceData); if (panelDataTypes != null) { foreach (PanelDataType panelDataType in panelDataTypes) { List <double> values = surfaceData.AnnualSurfaceResult <double>(panelDataType); if (values == null) { continue; } JArray jArray = new JArray(); values.ForEach(x => jArray.Add(x)); parameterSet.Add(panelDataType.Text(), jArray); } } PanelType panelType = Query.PanelType(surfaceData.BEType); PlanarBoundary3D planarBoundary3D = null; Panel panel = Analytical.Create.Panel(new Construction(surfaceData.BEName), panelType, planarBoundary3D); panel.Add(parameterSet); return(panel); }
public static Surface TogbXML(this Panel panel, List <Space> adjacentSpaces = null, int cADObjectIdSufix_Surface = -1, int cADObjectIdSufix_Opening = -1, double tolerance = Core.Tolerance.MicroDistance) { if (panel == null) { return(null); } PlanarBoundary3D planarBoundary3D = panel.PlanarBoundary3D; if (planarBoundary3D == null) { return(null); } Surface surface = new Surface(); if (cADObjectIdSufix_Surface == -1) { surface.Name = string.Format("{0} [{1}]", panel.Name, panel.Guid); } else { surface.Name = string.Format("{0} [{1}]", panel.Name, cADObjectIdSufix_Surface); } surface.id = Core.gbXML.Query.Id(panel, typeof(Surface)); //surface.constructionIdRef = Core.gbXML.Query.Id(panel.Construction, typeof(gbXMLSerializer.Construction)); surface.CADObjectId = Query.CADObjectId(panel, cADObjectIdSufix_Surface); surface.surfaceType = panel.PanelType.SurfaceTypeEnum(); surface.RectangularGeometry = planarBoundary3D.TogbXML_RectangularGeometry(tolerance); surface.PlanarGeometry = planarBoundary3D.TogbXML(tolerance); surface.exposedToSunField = Analytical.Query.ExposedToSun(panel.PanelType); if (adjacentSpaces != null && adjacentSpaces.Count > 0) { List <AdjacentSpaceId> adjacentSpaceIds = new List <AdjacentSpaceId>(); foreach (Space space in adjacentSpaces) { AdjacentSpaceId adjacentSpaceId = Query.AdjacentSpaceId(space); if (adjacentSpaceId == null) { continue; } adjacentSpaceIds.Add(adjacentSpaceId); } surface.AdjacentSpaceId = adjacentSpaceIds.ToArray(); } List <Aperture> apertures = panel.Apertures; if (apertures != null) { List <Opening> openings = new List <Opening>(); int cADObjectIdSufix_Opening_Temp = cADObjectIdSufix_Opening; foreach (Aperture aperture in apertures) { Opening opening = aperture.TogbXML(cADObjectIdSufix_Opening_Temp, tolerance); if (opening == null) { continue; } if (cADObjectIdSufix_Opening_Temp != -1) { cADObjectIdSufix_Opening_Temp++; } openings.Add(opening); } surface.Opening = openings.ToArray(); } return(surface); }