# Meshing separate parts in SegmentMesher

**URL:** https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188
**Category:** Support
**Tags:** meshing
**Created:** [February 10, 2020, 4:23pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188 "2020-02-10T16:23:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)
#### Post date: [February 10, 2020, 4:23pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188/1 "2020-02-10T16:23:25Z")

</div>

Hello all,  
I use SegmentMesher to mesh two segments that are in contact with each other. The slicer gives me just one vtk file (for both segments). I know that I have to use codes such as meshio to convert these files into the format I want, but how should I separate the segments and generate their mesh separately? Because now I get just one file in the slicer for both segments.  
Thanks

---

<div class="post-metadata">

### Author: ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)
#### Post date: [February 10, 2020, 6:10pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188/3 "2020-02-10T18:10:43Z")

</div>

Hello all,  
I am using SegmentMesher extension to mesh two different segments that are connected to each other. Actually the reason I am using SegmentMesher is that I want a mesh that is conformal in the boundaries of two objects that are in contact (a mesh that results in having the same nodes in the boundary), and I found SegmentMesher is capable to do that. My problem is that I have to export both of the objects in one model in the slicer and then save both of them as one file (vtk or vtu). I know that I can use codes such as meshio to convert vtk file into a mesh file that can be used in FEA software, but is there any way to separate the objects that I have? Because In fact I have two objects but I get one vtk file in the slicer.

 ![Capture](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/f/9fc1d69aeab6aa2538c8feb590bbbc9d70fcb434.png)  
Thank you for your help.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 10, 2020, 6:12pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188/4 "2020-02-10T18:12:04Z")

</div>

In general, you would want to preserve shared point IDs between submeshes, but if you are sure you don’t need that then you split the mesh using this short script: [https://github.com/lassoan/SlicerSegmentMesher/blob/master/README.md#split-mesh-to-submeshes](https://github.com/lassoan/SlicerSegmentMesher/blob/master/README.md#split-mesh-to-submeshes)

---

<div class="post-metadata">

### Author: ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)
#### Post date: [February 10, 2020, 6:25pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188/5 "2020-02-10T18:25:07Z")

</div>

Thank you very much for your response. I think that is exactly what I need. Can you please tell me where should I apply this code?  
I am new with slicer and I am using the windows GUI.  
Thanks for your help.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [February 10, 2020, 6:28pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188/6 "2020-02-10T18:28:51Z")

</div>

You can hit Ctrl-3 to bring up the Python console in Slicer and copy-paste the code there.

---

<div class="post-metadata">

### Author: ![Aep93](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/aep93/32/5990_2.png) [@Aep93](https://discourse.slicer.org/u/Aep93)
#### Post date: [February 10, 2020, 6:42pm UTC](https://discourse.slicer.org/t/meshing-separate-parts-in-segmentmesher/10188/7 "2020-02-10T18:42:57Z")

</div>

It is working now. Thank you very much for your help.
