diff --git a/Grids/Grid/src/Grid.cs b/Grids/Grid/src/Grid.cs index 3b2aea8..c91d497 100644 --- a/Grids/Grid/src/Grid.cs +++ b/Grids/Grid/src/Grid.cs @@ -91,8 +91,17 @@ private static List ExtractPolygonsFromElements(IEnumerable eleme 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; }