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 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); }