# Mesh multiple objects

**URL:** <https://discourse.slicer.org/t/mesh-multiple-objects/10384>\
**Category:** Support\
**Tags:** meshing\
**Created:** [February 21, 2020, 4:38pm UTC](https://discourse.slicer.org/t/mesh-multiple-objects/10384 "2020-02-21T16:38:43Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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 21, 2020, 11:54pm UTC](https://discourse.slicer.org/t/mesh-multiple-objects/10384/6 "2020-02-21T23:54:05Z")

</div>

With latest “curve drawing on surface” feature (to be announced next week, but already available in latest Slicer Preview Release) you can extract one side of a surface very easily:

- Draw a closed curve on the surface
- Make the curve snap to surface (enable Markups module / Curve settings / Curve type → shortest distance on surface, model node → model node that you would like to cut)
- Copy-paste this code snippet to the Python console

```python
# Get input data
curveNode = getNode('C')
modelNode = getNode('Segment_1')
extractLargestPart = False

# Get VTK data objects from MRML nodes
curvePoints = curveNode.GetCurvePointsWorld()
meshToClip = modelNode.GetMesh() # we should apply transform to World

# Clip model with curve
loop = vtk.vtkSelectPolyData()
loop.SetLoop(curvePoints)
loop.GenerateSelectionScalarsOn()
loop.SetInputData(meshToClip)
loop.SetSelectionModeToLargestRegion()
clip = vtk.vtkClipPolyData()
clip.InsideOutOn()
clip.SetInputConnection(loop.GetOutputPort())
clip.GenerateClippedOutputOn()
clip.Update()
clippedOutput = clip.GetOutput() if extractLargestPart else clip.GetClippedOutput()

# Remove unused points
cleaner = vtk.vtkCleanPolyData()
cleaner.SetInputData(clippedOutput)
cleaner.Update()
cleanedClippedOutput = cleaner.GetOutput()

# Save result to new node
clippedModel = slicer.modules.models.logic().AddModel(cleanedClippedOutput)
clippedModel.GetDisplayNode().SetActiveScalarName("")
clippedModel.GetDisplayNode().BackfaceCullingOff()

```

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/c/bc5ca7f5c110a99c4e6f486259509c985a206a84.png)

There are of course many alternative methods to edit and combine meshes - using VTK filters and/or using numpy.

---

_[View the full topic](https://discourse.slicer.org/t/mesh-multiple-objects/10384)._
