How to create FragmentedPatch in python

Does anyone have a suggestion on how to replicate the behavior of the FPatch node in Python? Specifically, I’m trying to create a fragmented patch from a polyline boundary.

I’m able to generate a standard patch, but that’s not what I need, as my input is always a polyline. From what I understand, the FPatch node is essentially a fast way to triangulate the boundary vertices. So I tried to replicate that, resulting in to working solutions. It produces an open Brep, similar to what the FPatch node outputs, but the ordering of the vertices is different, so the resulting patch doesn’t match. I’ve attached my Python attempt below, and in printscreen the surface edges for each of the different methods (red being Navilla GH)

Any ideas on how to ensure the result is identical to the native Grasshopper FPatch node?

python_fpatch_v2.gh (32.9 KB)

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.mesh/createfromclosedpolyline

I need to use FPatch in Python to join it with other Breps to get close brep, so the mesh method wouldn’t be ideal for my use case.

After further consideration, I’ve realized that since my input polyline curves are always somewhat bent, there probably isn’t just one way to create the surface. The surface creation will be influenced by the ordering of the boundary vertices one selects.

For consistency and to ensure compatibility with native nodes in the future, I’d prefer to implement the same approach that the native node uses. Does you have suggestions on how to achieve this? Or do you suggest using the CreateFromClosedPolyline method and then converting that mesh to a surface?

Yes, I was meaning that.
As the result is exactly the same shame as the node, I guess it is using that method inside.

1 Like

so close …

Noticed that the python method actually creates a brep identical to the fpatch, but when i tried to join it in python with other breps, the result is an invalid brep. Upon closer inspection, the method creates an addtional surface of close to 0 area size. And while the BrepJoin node can handle this edge case, the python method of joining breps doesn’t. Any suggestions? The attached script has both navilla and python methods

python_fpatch_v3.gh (47.7 KB)

Found alternative TriangulateClosedPolyline method that seems to at least give same sub-surface count. Now testing in actual code .. and that works python_fpatch_v4.gh (51.5 KB)

the question then remains why Mesh.CreateFromClosedPolyline method is not flawless

I haven’t looked at your files (on my phone), but indeed that method has also proved more reliable to me. This might be related/relevant to your case:

Ah, thanks, missed that post while searching, none the less, it’s related not the same. @dale , since you already replied to andres’s post and logged an issue, i am wondering what are your thoughts on this

1 Like

Just had a look now. I might be wrong, but I’m guessing Fragment Patch does something like this:



250419_FragmentPatch_GhPython_00.gh (8.5 KB)

The topology appears to be identical at least.