public static BHX.Opening ToGBXML(this BHE.Opening opening, List <BHE.Panel> space) { BHX.Opening gbOpening = opening.ToGBXML(); BHG.Polyline pLine = opening.Polyline(); if (pLine.NormalAwayFromSpace(space)) { gbOpening.PlanarGeometry.PolyLoop = pLine.Flip().ToGBXML(); } BHP.OriginContextFragment contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); if (contextProperties != null) { string elementID = contextProperties.ElementID; string familyName = contextProperties.TypeName; gbOpening.CADObjectID = opening.CADObjectID(); gbOpening.OpeningType = opening.Type.ToGBXML(); if (familyName == "System Panel") //No SAM_BuildingElementType for this one atm { gbOpening.OpeningType = "FixedWindow"; } if (gbOpening.OpeningType.Contains("Window") && opening.OpeningConstruction.Name.Contains("SLD")) //Change windows with SLD construction into doors { gbOpening.OpeningType = "NonSlidingDoor"; } } return(gbOpening); }
public static BHE.Opening ToBHoM(this BHX.Opening gbOpening) { BHE.Opening opening = new BHE.Opening(); BHG.Polyline pLine = gbOpening.PlanarGeometry.PolyLoop.ToBHoM(); opening.Edges = pLine.ToEdges(); string[] cadSplit = gbOpening.CADObjectID.Split('['); if (cadSplit.Length > 0) { opening.Name = cadSplit[0].Trim(); } if (cadSplit.Length > 1) { BHP.OriginContextFragment envContext = new BHP.OriginContextFragment(); envContext.ElementID = cadSplit[1].Split(']')[0].Trim(); envContext.TypeName = opening.Name; if (opening.Fragments == null) { opening.Fragments = new List <IBHoMFragment>(); } opening.Fragments.Add(envContext); } opening.Type = gbOpening.OpeningType.ToBHoMOpeningType(); return(opening); }
public static BHX.Opening ToGBXML(this BHE.Opening opening) { BHX.Opening gbOpening = new BHX.Opening(); BHG.Polyline pLine = opening.Polyline(); gbOpening.Name = opening.Name; gbOpening.ID = "opening" + opening.BHoM_Guid.ToString().Replace("-", "").Substring(0, 5); gbOpening.PlanarGeometry.PolyLoop = pLine.ToGBXML(); gbOpening.PlanarGeometry.ID = "openingPGeom-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5); gbOpening.RectangularGeometry.CartesianPoint = Geometry.Query.Centre(pLine).ToGBXML(); gbOpening.RectangularGeometry.Height = Math.Round(opening.Height(), 3); //TODO: temporary solution to get valid file to be replaced with correct height if (opening.Height() == 0) { gbOpening.RectangularGeometry.Height = 0.1; } gbOpening.RectangularGeometry.Width = Math.Round(opening.Width(), 3); //if (opening.Width() == 0) // gbOpening.RectangularGeometry.Width = 0.1; gbOpening.RectangularGeometry.ID = "rGeomOpening-" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 5); return(gbOpening); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static List <BH.oM.XML.Opening> SerializeOpenings(IEnumerable <BH.oM.Environment.Elements.Opening> openings, List <Panel> space, List <Panel> allElements, List <List <Panel> > spaces, BH.oM.XML.GBXML gbx, XMLSettings settings) { List <BH.oM.XML.Opening> gbOpenings = new List <oM.XML.Opening>(); foreach (BH.oM.Environment.Elements.Opening opening in openings) { Polyline openingPoly = opening.Polyline(); if (openingPoly == null || openingPoly.CleanPolyline(distanceTolerance: settings.DistanceTolerance) == null) { continue; } openingPoly = openingPoly.CleanPolyline(distanceTolerance: settings.DistanceTolerance); BH.oM.XML.Opening gbOpening = BH.Engine.XML.Convert.ToGBXML(opening); //Normals away from space if (!BH.Engine.Environment.Query.NormalAwayFromSpace(openingPoly, space)) { gbOpening.PlanarGeometry.PolyLoop = BH.Engine.XML.Convert.ToGBXML(openingPoly.Flip()); } Panel buildingElement = new Panel(); ; BHP.OriginContextFragment contextProperties = opening.FindFragment <BHP.OriginContextFragment>(typeof(BHP.OriginContextFragment)); string elementID = ""; string familyName = ""; if (contextProperties != null) { elementID = contextProperties.ElementID; familyName = contextProperties.TypeName; } gbOpening.CADObjectID = opening.CADObjectID(); gbOpening.OpeningType = opening.Type.ToGBXML(); if (gbOpening.OpeningType.ToLower() == "fixedwindow" && contextProperties != null && contextProperties.TypeName.ToLower().Contains("skylight")) { gbOpening.OpeningType = "FixedSkylight"; } if (familyName == "System Panel") //No SAM_BuildingElementType for this one atm { gbOpening.OpeningType = "FixedWindow"; } if (settings.ReplaceSolidOpeningsIntoDoors && gbOpening.OpeningType.Contains("Window") && (opening.OpeningConstruction != null && opening.OpeningConstruction.Name.Contains("SLD"))) //Change windows with SLD construction into doors for IES { gbOpening.OpeningType = "NonSlidingDoor"; } if (settings.IncludeConstructions) { gbOpening.WindowTypeIDRef = "window-" + (contextProperties != null? contextProperties.TypeName.CleanName() : (opening.OpeningConstruction != null ? opening.OpeningConstruction.Name.CleanName() : "")); } else { gbOpening.WindowTypeIDRef = null; } gbOpening.ConstructionIDRef = null; //ToDo review having this property on an opening? gbOpenings.Add(gbOpening); } return(gbOpenings); }