Rhino 7; SplitMeshWithCurve issue

Hello,

I’m in the process of converting Rhino 5 scripts into Rhino 7 scripts, and I got weird results using SplitMeshWithCurve function.

Here is the mesh I’m tring to split, with the splitting curve:

Here is the result:

The big mesh remains, and some triangles make another mesh (shown in yellow)

Here is the testing code:

mesh = rs.ObjectsByLayer(“Input_Mesh”)[0]
curve = rs.ObjectsByLayer(“Input_Curve”)[0]

cmd="-_SplitMeshWithCurve " + "_Selid " + str(rs.CopyObject(mesh)) + " " + "_Selid " + str(curve) + " _Enter " + " _Enter "
rs.Command(cmd, echo=True)
split = rs.LastCreatedObjects()

And the 3dm: SplitMeshWithCurveBug.3dm (1.0 MB)

Thank you!

Alexandre Filiatrault

Hey Alexandre,

we didn’t get to imprioving the _SplitMeshWithCurve command in V7. However, I am not aware of changes in the 5 to 7 timeframe.

We are improving _MeshSplit itself, which in version 7 SR2 is capable of splitting that mesh, if the curve is not projected on the mesh first. The problem when it’s projected first, is that there are some minimal changes in the way the projector and the intersector define the two respective operations, and that creates tiny fractures along the split. These are similar places where the old MeshSplitWithCurves was failing. However, if you don’t project first, V7 SR2 MeshSplit splits the mesh easily. I am attaching an example. I regenerated the curve by simply rebuiling (_Rebuild) it in degree 3.

MeshSplit-Alexandre-v7sr2.3dm (1.5 MB)

There’s a plan on improving MeshSplit so that it’s more aggressive and can bypass or ignore these microgaps.

For now, to get SR2, you can use this option:

Please note that Rhino V7 SR0 and SR1 have more limitations when it comes to MeshSplit, so they will work a bit less reliably.

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Hello Giulio,

Thanks for your answer! I did the upgrade to the SR2 version. Then tried what you say here: rebuild the curve. The result is much better (the mesh is split!) but some issues remain. Here is a similar test case:

SplitAndMeshCurves_TestCase.3dm (824.7 KB)

The testing code (adding rs.RebuildCurve; maybe should I use some other parameters?)

mesh  = rs.ObjectsByLayer("Input_Mesh")[0]
curve = rs.ObjectsByLayer("Input_Curve")[0]

extended = rs.ExtendCurveLength(curve, 2, 2, 100)

rs.RebuildCurve(extended, 3, 100)

cmd="-_SplitMeshWithCurve " + "_Selid " + str(rs.CopyObject(mesh)) + " " + "_Selid " + str(curve) + " _Enter " + " _Enter "
rs.Command(cmd, echo=True)
split = rs.LastCreatedObjects()

Here is the result:

I have another question regarding that case, about rs.ExtendCurveLength

Here I call it to extend at both sides. However the extension is much longer on the left side, compared to the right side.

Is there something I’m doing incorrectly?

Thank you again!

Alexandre Filiatrault

Oups, I forgot about the 3ed dimension! The second part of my question is invalid!

Are these methods available through rhinoscriptsyntax or RhinoCommon as well? Do you have an example you could share?

I will answer myself here: After having forgotten about the 3rd dimension, I tried removing the extension. I did the opposite: shorten the cutting curve removing parts that were not directly over the mesh.

The result is very good this time. If I get some others issues about that function, I’ll post them here.

Thanks!

Alexandre

1 Like

So, as you probably realized, MeshSplit extrudes/uses parallel projection to split. SplitMeshWithCurve, on the other hand, pulls to the mesh.

Which methods would you need? MeshSplit or SplitMeshWithCurve?
I reported RH-62090 but there’s Mesh.CreateFromCurveExtrusion in V7 that allows to create a splitter mesh from a curve.

Does it mean that your question got answered? It’s fine and probably better if you start new threads if the new issue is tangential.

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Does it mean that your question got answered?

Partially! At the moment it seems to me that SplitMeshWithCurve can work but is somewhat fragile.

Here is a slightly modified 3dm: the splitting curve does not extend at all past the mesh, here.

SplitAndMeshCurves_TestCase2.3dm (1020.3 KB)

I run the test code above, modifying the extension length. After some tests, I realized the results depend heavily on the length used. Here are what I’ve got:

Extended 0.1 → fail
Extended 0.2 → fail
Extended 0.4 → fail
Extended 0.5 → good result
Extended 0.6 → Split, but small artefacts on sides
Extended 0.7 → fail
Extended 1.0 → Split, with artefacts
Extended 100 (as shown above) → Split w artefacts

So that where I am at the moment. I’ve got it to work in testing, but in production there will be nobody to review the result. I am afraid its not robust enough to use for our use case if we have to guess the correct extension length

I have not tried MeshSplit yet; that is my next step. I guess that design (I mean extrusion/parallel projection) should be more stable? Is that what you would recommend for that job?

Thanks!

Alexandre

Yes, I think that pulling is not a great idea for stability, because, as you noticed, it’s hard to determine the amount of extension that might be needed, or what to do in general toward the end of the curve.

Ideally, you’d find an independent plane or mesh to use for splitting.

Hi @piac

The link to the YouTrack item gives me a 404

So to script this, the pipeline (given an existing mesh to cut and an associated cutting curve) would look something like:

  1. Extrude the curve as a mesh using Mesh.CreateFromCurveExtrusion(…)
  2. Split the mesh using Mesh.Split(…)

Is that correct?

In the help file for Mesh.Split it states: Suggestion: upgrade to overload with tolerance. Can you please clarify this? Is this a ToDo item for McNeel?

Thanks; I’ve made it public.

Yes, that is one way to split that is similar to the command, but is not yet in RhinoCommon.

No, it’s a suggestion to upgrade to this: https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Mesh_Split_3.htm
or to this:
https://developer.rhino3d.com/wip/api/RhinoCommon/html/M_Rhino_Geometry_Mesh_Split_4.htm

Eventually, this overload without tolerance will be marked obsolete, and then it will be removed (I think this is far away in time, though).

A post was split to a new topic: Making MeshSplit work on this geometry