SplitMeshWithCurve deletes mesh in rhino 6

Hi,
I am rewriting scripts written in Rhino5 to make them compatible in Rhino6. I have encountered a problem with the SplitMeshWithCurve command. After I execute the command, the mesh is deleted and only the curve remains. Here is the script:

import rhinoscriptsyntax as rs

originalMesh = rs.GetObject('Select mesh to split')
curve = rs.GetObject('Select cutting curve')

cmd="-_SplitMeshWithCurve " + "_Selid " + str(originalMesh) + " " + "_Selid " + str(curve) + " _Enter " + " _Enter "
rs.Command(cmd)
result = rs.LastCreatedObjects()

And this is the test file I used:
SplitMeshWithCurveBug.3dm (663.4 KB)

The variable result contains two objects at the end, however the mesh disappears. In Rhino5 the command works as expected.

Thank you for your help.

Hello - I see this, thanks for the report.
https://mcneel.myjetbrains.com/youtrack/issue/RH-46901

-Pascal

Hi,

Is there any work around for this? I am currently looking at whether to upgrade to Rhino 6, but this is a command that I use all the time.

Cheers,
Chris

In Rhino 6 SplitMeshWithCurve does not work on any mesh, but MeshSplit works with the same curves and meshes.

This is not true. It needs a great deal of improvement, granted, but it is not helpful to simply make stuff up.

-Pascal

Some of my meshes do split, but not all. I couldn’t get MeshSplit to work with a curve, but If i extrude it through the mesh then I can use it to split.

Cheers,
Chris

If there is any additional info though I would appreciate it, as the extrude method isn’t always going to work for me. The bug seems to be related to the mesh rather than the curve. In particular how it was created seems to matter. From the little bit of testing I have done:

Meshes that split properly

  • Imported mesh from obj file
  • Create a mesh sphere/cube/cylinder etc

Meshes that disappear

  • Meshfrompoints
  • Create a solid sphere/cube/cylinder etc, convert to mesh
  • Offsetmesh (EDIT: Depends on the input mesh)

Things that don’t change behaviour

  • Reducemesh
  • Changelayer
  • Copy/Paste
  • Meshsplit
  • Deletemeshfaces

Things that do change behaviour

  • Export as obj and reinsert (goes from busted to working)

I’m not sure if there are any clues there as to the cause?

Cheers,
Chris

SplitMeshWithCurveBug2.3dm (87.3 KB)

I have reduced the bug to the simplest form I could. One layer has a single mesh face created from a square surface using the ‘mesh’ command. The second has a single mesh face created directly from the ‘_3DFace’ command.

I then projected a circle onto the two meshes. The first layer fails to split, and the mesh disappears, whereas the second splits fine.

Cheers,
Chris

EDIT: Having another look at this file, and the properties of the meshes, I can see that the one that works is a double precision mesh whereas the other is not. Having a look at some of my other files it seems that all the ones that disappear are not double precision. Is there a way to convert them? This would solve all my issues.

Hi Chris - it doesn’t deal with the core of the problem but a workaround is to move the mesh “very far” from the origin. In your file, moving the objects on the “Meshed Surface” layer from the world origin to 100000000,0,0 converts the mesh to a double precision mesh and then using SplitMeshWithCurve yields the correct result. It is entirely possible (even likely) that you can convert them using code but I wouldn’t know about that…
-wim

1 Like

Thanks Wim,

Yes moving it far away and then back again does work to convert it to double precision. I can include this in my script as a workaround until the bug is fixed.

Cheers,
Chris

Hi Chris - I’ve created an extra bug item for this one - RH-56568 - as it seems to me to be easier to automatically convert meshes to double precision and make the command work in many (?) cases than to solve all possible problems with the SplitMeshWithCurve command.
It doesn’t solve the issue with the OP’s file though…
-wim

Hi Wim,

This does also work for the OPs file. If I move his mesh very far away and back again it turns into a double precision mesh and I can split it. The line included in the file wont split it cleanly though, I guess its not perfectly on the mesh after moving it away and back, but any new lines I draw or project onto the mesh split it fine.

This is also the case for RH-53063. The meshes in the attached file there are also not double precision. Moving them far away and back again fixes the problem.

So I think:
RH-53063
RH-56568
RH-46901

are all the same bug.

Cheers,
Chris

Thanks for that information, Chris!
-wim