/// <summary> /// Tessellate the surface by calling the ToRevitType function. /// If it fails, each edge of the surface will be tessellated instead by calling /// the correspoinding Tessellate method. /// </summary> /// <param name="surface"></param> /// <returns></returns> private List <GeometryObject> Tessellate(Surface surface) { List <GeometryObject> rtGeoms = new List <GeometryObject>(); try { rtGeoms.AddRange(surface.ToRevitType()); } catch (Exception) { // Add a red bounding box geometry to identify that some errors occur var bbox = surface.BoundingBox; rtGeoms.AddRange(ProtoToRevitMesh.CreateBoundingBoxMeshForErrors(bbox.MinPoint, bbox.MaxPoint)); foreach (var edge in surface.Edges) { if (edge != null) { var curveGeometry = edge.CurveGeometry; rtGeoms.AddRange(Tessellate(curveGeometry)); curveGeometry.Dispose(); edge.Dispose(); } } } return(rtGeoms); }