From 07242466313b0062d77858a94ff123acca24d297 Mon Sep 17 00:00:00 2001 From: James Bradley Date: Fri, 5 Jan 2024 13:13:32 -0500 Subject: [PATCH 1/2] handle nulls in ExtractPolygonsFromElements - some roof elements had null values in their solidoperations + profiles --- Grids/Grid/src/Grid.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Grids/Grid/src/Grid.cs b/Grids/Grid/src/Grid.cs index 3b2aea8..49f0f61 100644 --- a/Grids/Grid/src/Grid.cs +++ b/Grids/Grid/src/Grid.cs @@ -88,11 +88,22 @@ public static GridOutputs Execute(Dictionary inputModels, GridInp /// If this returns null, we'll use the 2D convex hull of the geometry of the element's representation private static List ExtractPolygonsFromElements(IEnumerable elements, Func getDefaultPolygon) where T : GeometricElement { + List warnings = new List(); + var polygons = new List(); foreach (var element in elements) { - var polygon = getDefaultPolygon(element) ?? ConvexHull.FromPoints(element.Representation.SolidOperations.SelectMany(o => o.Solid.Vertices.Select(v => new Vector3(v.Value.Point.X, v.Value.Point.Y)))); - polygons.Add(polygon); + var polygon = getDefaultPolygon(element) ?? + ConvexHull.FromPoints( + element?.Representation?.SolidOperations? + .SelectMany(o => o?.Solid?.Vertices? + .Select(v => new Vector3(v.Value.Point.X, v.Value.Point.Y)) ?? Enumerable.Empty()) + .Where(v => v != null) + ); + if (polygon != null) + { + polygons.Add(polygon); + } } return polygons; } From 262b6c36f2e67bdea62be4ee3d82c3b38eba8063 Mon Sep 17 00:00:00 2001 From: James Bradley Date: Thu, 11 Jan 2024 09:49:39 -0500 Subject: [PATCH 2/2] remove unused warning array --- Grids/Grid/src/Grid.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Grids/Grid/src/Grid.cs b/Grids/Grid/src/Grid.cs index 49f0f61..c91d497 100644 --- a/Grids/Grid/src/Grid.cs +++ b/Grids/Grid/src/Grid.cs @@ -88,8 +88,6 @@ public static GridOutputs Execute(Dictionary inputModels, GridInp /// If this returns null, we'll use the 2D convex hull of the geometry of the element's representation private static List ExtractPolygonsFromElements(IEnumerable elements, Func getDefaultPolygon) where T : GeometricElement { - List warnings = new List(); - var polygons = new List(); foreach (var element in elements) {