TriangulateClosedPolyline

Hi,

I get a problem with creating TriangulateClosedPolyline, the command doesn’t succeed on closed polyline, is it because the mesh can not be created for current polyline? This is what I do:

            if (polyLine.IsClosed)
            {
                var meshFace = polyLine.TriangulateClosedPolyline();

                Mesh mesh = new Mesh();
                mesh.Faces.AddFaces(polyLine.TriangulateClosedPolyline());
                mesh.Normals.ComputeNormals();
                mesh.UnifyNormals();
                mesh.Compact();
                doc.Objects.AddMesh(mesh);
            }

and it crashes on mesh.Compact();
What could be wrong here?

Can you post the offending polyline?