# Explode Mesh

**URL:** <https://discourse.mcneel.com/t/explode-mesh/19911>\
**Category:** Rhino Developer\
**Created:** [May 11, 2015, 10:35am UTC](https://discourse.mcneel.com/t/explode-mesh/19911 "2015-05-11T10:35:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stratos](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Stratos](https://discourse.mcneel.com/u/Stratos)\
**Post date:** [May 11, 2015, 10:35am UTC](https://discourse.mcneel.com/t/explode-mesh/19911/1 "2015-05-11T10:35:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Willem](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/willem/32/773637_2.png) [@Willem](https://discourse.mcneel.com/u/Willem)\
**Post date:** [May 11, 2015, 10:50am UTC](https://discourse.mcneel.com/t/explode-mesh/19911/2 "2015-05-11T10:50:51Z")

</div>

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

```python
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

---

<div class="post-metadata">

**Author:** ![Stratos](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Stratos](https://discourse.mcneel.com/u/Stratos)\
**Post date:** [May 12, 2015, 7:42am UTC](https://discourse.mcneel.com/t/explode-mesh/19911/3 "2015-05-12T07:42:46Z")

</div>

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 😄

Thank you.  
Stratos

---

<div class="post-metadata">

**Author:** ![dale](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/dale/32/772741_2.png) [@dale](https://discourse.mcneel.com/u/dale)\
**Post date:** [May 13, 2015, 12:21am UTC](https://discourse.mcneel.com/t/explode-mesh/19911/4 "2015-05-13T00:21:51Z")

</div>

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