diff --git a/XML_Adapter/Serialise/Opening.cs b/XML_Adapter/Serialise/Opening.cs index c97bff87..d83e3198 100644 --- a/XML_Adapter/Serialise/Opening.cs +++ b/XML_Adapter/Serialise/Opening.cs @@ -53,13 +53,17 @@ public partial class GBXMLSerializer foreach (BH.oM.Environment.Elements.Opening opening in openings) { - if (opening.Polyline() == null) continue; + 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(opening.Polyline(), space)) - gbOpening.PlanarGeometry.PolyLoop = BH.Engine.XML.Convert.ToGBXML(opening.Polyline().Flip()); + if (!BH.Engine.Environment.Query.NormalAwayFromSpace(openingPoly, space)) + gbOpening.PlanarGeometry.PolyLoop = BH.Engine.XML.Convert.ToGBXML(openingPoly.Flip()); Panel buildingElement = new Panel(); ; diff --git a/XML_Engine/Create/XMLSettings.cs b/XML_Engine/Create/XMLSettings.cs index 1831b5d0..c0528d12 100644 --- a/XML_Engine/Create/XMLSettings.cs +++ b/XML_Engine/Create/XMLSettings.cs @@ -48,8 +48,9 @@ public static partial class Create [Input("newFile", "Set to false if you want to append to a file when pushing XML. If set to true then a file will be created. If a file exists, it will be overwritten. Default true")] [Input("unitType", "Set the unit type for the export to be either SI or Imperial. Default SI")] [Input("exportDetail", "Set the detail of your export to be either full (whole building), shell (exterior walls only), or spaces (each individual space as its own XML file). Default full")] + [Input("distanceTolerance", "distanceTolerance is used as input for CleanPolyline method used for opening")] [Output("xmlSettings", "The XML settings to use with the XML adapter push")] - public static XMLSettings XMLSettings(bool replaceCurtainWalls = false, bool replaceSolidOpeningsIntoDoors = false, bool includeConstructions = false, bool fixIncorrectAirTypes = false, bool newFile = true, UnitType unitType = UnitType.SI, ExportDetail exportDetail = ExportDetail.Full) + public static XMLSettings XMLSettings(bool replaceCurtainWalls = false, bool replaceSolidOpeningsIntoDoors = false, bool includeConstructions = false, bool fixIncorrectAirTypes = false, bool newFile = true, UnitType unitType = UnitType.SI, ExportDetail exportDetail = ExportDetail.Full, double distanceTolerance = 0.01) { return new XMLSettings { @@ -60,6 +61,7 @@ public static XMLSettings XMLSettings(bool replaceCurtainWalls = false, bool rep NewFile = newFile, UnitType = unitType, ExportDetail = exportDetail, + DistanceTolerance = distanceTolerance }; } } diff --git a/XML_oM/XMLSettings.cs b/XML_oM/XMLSettings.cs index e1452d47..9d9978ce 100644 --- a/XML_oM/XMLSettings.cs +++ b/XML_oM/XMLSettings.cs @@ -40,6 +40,7 @@ public class XMLSettings : BHoMObject public bool NewFile { get; set; } = true; public UnitType UnitType { get; set; } = UnitType.SI; public ExportDetail ExportDetail { get; set; } = ExportDetail.Full; + public double DistanceTolerance { get; set; } = 0.01; /***************************************************/ }