Preserve Rhino Ngon structure when doing ToPlanktonMesh()

Hi @DanielPiker and @will ,

I notice that when I am doing the .ToPlanktonMesh() and .ToRhinoMesh() afterwards, the ngon structure supported by Rhino 6 gets lost. I need the plankton halfedge structure for some mesh manipulation. But I want to preserve the ngons on the mesh. Any suggestions?

Thank you in advance,
Vincent

Hey @vincentfs, Plankton was written before Rhino 6 was released, so it never supported ngons. You’ll need to construct the plankton mesh yourself from the ngons. For example, in python…

p = Plankton.PlanktonMesh()

for v in mesh.Vertices:
    p.Vertices.Add(v.X, v.Y, v.Z)

for n in mesh.Ngons:
    verts = [int(i) for i in n.BoundaryVertexIndexList()] # hack to convert unit[] to int[]
    p.Faces.AddFace(verts)

Here’s a Grasshopper example… ngon_to_plankton.gh (7.3 KB)

1 Like

Thank you @will . Is it possible to share the original .ToPlanktonMesh() and .ToRhinoMesh() source codes? I would like to rewrite them for ngon supporting in python.

@vincentfs, the source code is on GitHub. It’s C# though.

2 Likes

@diff-arch Awesome! Thank you!