Explode Mesh

Hello

Is there any function in the Rhino SDK that I could use to ‘explode’ meshes they way Rhino does when using the Explode command?

It will also be useful to have an idea of the logic by which the Explode command explodes meshes?

Thank you.

Stratos

Hi Stratos,

Exploring the python method I found a mesh object has the method ExplodeAtUnweldedEdges()
it also answers the question what the logic is: separate by unwelded edges

def ExplodeMeshes(mesh_ids, delete=False):
    """Explodes a mesh object, or mesh objects int submeshes. A submesh is a
    collection of mesh faces that are contained within a closed loop of
    unwelded mesh edges. Unwelded mesh edges are where the mesh faces that
    share the edge have unique mesh vertices (not mesh topology vertices)
    at both ends of the edge
    Parameters:
      mesh_ids = list of mesh identifiers
      delete[opt] = delete the input meshes
    Returns:
      List of identifiers
    """
    id = rhutil.coerceguid(mesh_ids)
    if id: mesh_ids = [mesh_ids]
    rc = []
    for mesh_id in mesh_ids:
        mesh = rhutil.coercemesh(mesh_id, True)
        if mesh:
            submeshes = mesh.ExplodeAtUnweldedEdges()
            if submeshes:
                for submesh in submeshes:
                    id = scriptcontext.doc.Objects.AddMesh(submesh)
                    if id!=System.Guid.Empty: rc.append(id)
    if rc: scriptcontext.doc.Views.Redraw()
    return rc

HTH
-Willem

Thanks Willem.

That would be perfect. Unfortunately, I don’t use RhinoCommon (yet).
Nevertheless, it clearly demonstrates the logic of the process, which can be useful :smile:

Thank you.
Stratos

Use RhinoExplodeMesh(). See rhionSdkMeshUtilities.h for details.