public static BHX.Surface ToGBXML(this BHE.Panel element) { BHP.OriginContextFragment contextProperties = element.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); BHX.Surface surface = new BHX.Surface(); surface.CADObjectID = element.CADObjectID(); surface.ConstructionIDRef = (contextProperties == null ? element.ConstructionID() : contextProperties.TypeName.CleanName()); BHX.RectangularGeometry geom = element.ToGBXMLGeometry(); BHX.PlanarGeometry planarGeom = new BHX.PlanarGeometry(); planarGeom.ID = "PlanarGeometry-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10); BHG.Polyline pLine = element.Polyline(); planarGeom.PolyLoop = pLine.ToGBXML(); surface.PlanarGeometry = planarGeom; surface.RectangularGeometry = geom; surface.Opening = new BHX.Opening[element.Openings.Count]; for (int x = 0; x < element.Openings.Count; x++) { if (element.Openings[x].Polyline().IControlPoints().Count != 0) { surface.Opening[x] = element.Openings[x].ToGBXML(); } } return(surface); }
public static BHX.Surface ToGBXML(this BHE.Panel element, List <List <BHE.Panel> > adjacentSpaces, List <BHE.Panel> space) { BHX.Surface surface = element.ToGBXML(); surface.SurfaceType = element.ToGBXMLType(adjacentSpaces); surface.ExposedToSun = Query.ExposedToSun(surface.SurfaceType).ToString().ToLower(); BHG.Polyline pLine = element.Polyline(); if (!pLine.NormalAwayFromSpace(space)) { pLine = pLine.Flip(); surface.PlanarGeometry.PolyLoop = pLine.ToGBXML(); surface.RectangularGeometry.Tilt = Math.Round(pLine.Tilt(), 3); surface.RectangularGeometry.Azimuth = Math.Round(pLine.Azimuth(BHG.Vector.YAxis), 3); } List <BHX.AdjacentSpaceId> adjIDs = new List <BHX.AdjacentSpaceId>(); foreach (List <BHE.Panel> sp in adjacentSpaces) { adjIDs.Add(sp.AdjacentSpaceID()); } surface.AdjacentSpaceID = adjIDs.ToArray(); return(surface); }
public static BHE.Panel ToBHoM(this BHX.Surface surface) { BHE.Panel panel = new BHE.Panel(); surface.Opening = surface.Opening ?? new List <BHX.Opening>().ToArray(); panel.ExternalEdges = surface.PlanarGeometry.PolyLoop.ToBHoM().ToEdges(); foreach (BHX.Opening opening in surface.Opening) { panel.Openings.Add(opening.ToBHoM()); } string[] cadSplit = surface.CADObjectID.Split('['); if (cadSplit.Length > 0) { panel.Name = cadSplit[0].Trim(); } if (cadSplit.Length > 1) { BHP.OriginContextFragment envContext = new BHP.OriginContextFragment(); envContext.ElementID = cadSplit[1].Split(']')[0].Trim(); envContext.TypeName = panel.Name; if (panel.Fragments == null) { panel.Fragments = new List <IBHoMFragment>(); } panel.Fragments.Add(envContext); } panel.Type = surface.SurfaceType.ToBHoMPanelType(); panel.ConnectedSpaces = new List <string>(); if (surface.AdjacentSpaceID != null) { foreach (BHX.AdjacentSpaceId adjacent in surface.AdjacentSpaceID) { panel.ConnectedSpaces.Add(adjacent.SpaceIDRef); } } return(panel); }