Splitting Mesh with Multiple Disjoint Parts Makes Uncut Meshes Disappear

So I encountered this bug/issue today and wanted to share it with you.
I have the following model that contains a mesh which is basically 3 meshes joined together:
potato chip cutting machine
split_mesh_disappears
(I hope you can see that in the picture. The holes are for screws to put everything together.)

So then I use a plane to cut through the meshes by using the Mesh.Split method on every mesh in the layer which returns an array of meshes that is incomplete sometimes and I think it does that for every mesh that is a disjoined part of a “bigger mesh” and that didn’t get cut through by the plane:

Here are example pictures for clarification:

split_mesh_disappears_1
split_mesh_disappears_2

I think you can see what mesh is disappearing / which one is missing, right? So in the case when I call mesh.Split() with a mesh that has a DisjointMeshCount > 1, meshes start to disappear if the plane didn’t cut through them, because not all the disjoint parts get returned inside the array of meshes by the split method.

This does also happen when I do this manually in Rhino itself and not in code.
I know the workaround for this but wouldn’t it be nicer if this didn’t happen?

Hi @Ivan1,

Can you provide a model that contains the mesh and the cutting plane?

– Dale

@dale Yes, here:
potato-cutter-test.3dm (2.2 MB)

Now using MeshSplit causes for this to happen:
potato-cutter-test_after.3dm (1.2 MB)

Hi @Ivan1,

I think you should split up a mesh object into its unconnected, or disjoint, pieces before you try to split the mesh with the cutting plane.

Mesh.SplitDisjointPieces

– Dale

@dale, yes right, that’s the work-around that I use and before splitting the meshes up into its unconnected pieces I store the information about what mesh was previoulsy connected to which other meshes so that I can use Mesh.Append to have the connectivity again after splitting (and rotating and doing certain other things).