I am trying to use the
mesh.Split() function from Rhinocommon Python, assuming a meshplane that has to be splitted by multiple splitters (extruded meshes from polylines). This function works perfectly when given one splitter, but it does not work as I would expect with multiple splitters, see my attached file:
example.gh (80.7 KB)
Could someone suggest me how to fix this problem? I have considered to split the mesh step by step given only one splitter, but I do not know how to decide which element I should keep after splitting…
Thank you for your time!
splitting meshes with other meshes in Rhino never has been 100% reliable unless you have clear intersections and all input meshes are rather simple. I’ve found that often i get better results if i triangulate all input meshes and use
Mesh.SplitWithProjectedPolylines instead. Whenever i can avoid mesh related operations i prefer to do it using breps and curves.
Your example shows some problems already with the cutter meshes having self intersections. As long as you have cases like this,
Mesh.Split will likely fail to split the mesh plane.
Having coincident mesh edges in the split operation as shown below is not recommended:
Better would be to try to extend the splitter mesh away from the mesh plane so it is a clear intersection. If you’re unsure if the operation will succeed, just intersect the meshes and analyze the resulting polylines. If they overlap, it is likely that the split will fail.
Having coincident faces in your cutter meshes as shown below will likely prevent that the split operation will find the expected result. Remember, you’re passing all these cutters to a single
Another reason why mesh splitting often fails are tolerances. If your cutters or the mesh to split has mesh edges smaller then the file tolerance, the resulting mesh usually gets only partially split but stays a single mesh. If you’re not sure about the file tolerance i would suggest to use a flavour of
Mesh.Split which allows to specify a tolerance.
You should try this in the Rhino 8 WIP.
i did and V8 is a big improvement. But the input quality still decides the outcome.
Hi @clement and @dale,
Thanks for all the suggestions! First of all, I missed that my polylines have self-intersections. This is probably because I am using an external dataset based on pointcloud data. Unfortunately I am trying to automate the process I described, so any manual rework on the self-intersections is not possible.
Based on your suggestions I just tried to use the
Mesh.SplitWithProjectedPolylines() but it resulted in a way higher number of splitted elements than I was expecting.
In the end my solution was to use
mesh.Split() and loop over all the splitters. In each iteration I take the meshes and extract a random face centroid (after some mesh post processing). Then I check if that centroid is in of the polylines or not, so that I know which part to keep for the next step.
Good to know that Rhino V8 gives better results, but for now I will have to keep working in R7.