Mesh.SplitWithProjectedPolylines Problem

I try to write a C# component which splits a mesh by a polyline. See attached screenshot and gh file. The mesh does not split correctly. When I pull the curve to the mesh in Rhino and use the pulled curve in the component the spilt is correct. Any idea what the issue could be?


SplitMEshbyPolyline.gh (11.9 KB)

What you’re looking for is Curve.ProjectToMesh()
https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Curve_ProjectToMesh.htm

Pulling a curve will snap it’s control points to the closest mesh vertex which is probably not what you need.

Try Plan B

Mesh_Split_EntryLevel_V1.gh (13.8 KB)

PS: Add the required checks and Print appropriate messages.

I think there is also a bug in Mesh Split. It didn’t worked for me so I developped some tools.

If you extrude the curve to a mesh and use mesh split it works

Mout = M.Split(splitters);

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Mesh_Split_2.htm

Many thanks for all the answers.
At the end I want to split a non planar mesh. Also I want to use polylines which are connecting the mesh edges. Therfore the idea of SplitMeshByPolyline is what I thought might be the ideal solution. Unfortuantely mesh splitting is still not reliable in Rhino. Even with extruding a mesh as a splitter, I get sometimes problem with not correct splits.

It is the reason I had to develop some tools. Some hundreds of lines of C# code. The main tool localize the intersection on a triangle mesh (work in UV), … I hope to publish this plugin with the dll used, at the end of the year.

R8 has some better Mesh Bolean but I don’t know if it works better for the mesh splitting. I made some tests without being happy.

Hi Laurent -

The updated code is in split functions as well. This work is ongoing, though, so please post things you are not happy with.
-wim

BTW: If you want to create a “boundary Loop” of Mesh Edges (due to some recursive grow logic: for instance using some guide Poly) then there’s no reason to attempt to Split the Mesh: just use VV Connectivity and get your Mesh(es).

Maybe this method is useful

  private void RunScript(Mesh mesh, List<Curve> crv, Vector3d direction, ref object A, ref object Meshexploded)
  {
    if(mesh != null && crv != null){
      var tmp = new List < PolylineCurve >();
      foreach(var t in crv)
        tmp.Add(mesh.PullCurve(Curve.ProjectToMesh(t, mesh, direction, 0.00001)[0], 1e-6)); // where mesh is the mesh, and crv is the curve

      Mesh[] splits = mesh.SplitWithProjectedPolylines(tmp, 1e-4);
      
 

      Meshexploded = splits;}

SplitMEshbyPolyline++.gh (16.7 KB)