# How to extract surface from polydata

**URL:** https://discourse.vtk.org/t/how-to-extract-surface-from-polydata/321
**Category:** Support
**Created:** [February 25, 2019, 11:14am UTC](https://discourse.vtk.org/t/how-to-extract-surface-from-polydata/321 "2019-02-25T11:14:54Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![banesullivan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/banesullivan/32/7143_2.png) [@banesullivan](https://discourse.vtk.org/u/banesullivan)
#### Post date: [February 27, 2019, 2:55am UTC](https://discourse.vtk.org/t/how-to-extract-surface-from-polydata/321/4 "2019-02-27T02:55:06Z")

</div>

~~@cory.quammen, I also cannot get the `vtk.vtkBooleanOperationPolyDataFilter` filter to work:~~  
The `vtk.vtkBooleanOperationPolyDataFilter` needs triangulated poly data as inputs.

```python
import vtki
import vtk

# create cylinders and triangulate the meshes
c1 = vtki.Cylinder((0,0,0), (1,0,0), 2, 20).tri_filter()
c2 = vtki.Cylinder((0,0,0), (1,1,0), 2, 20).tri_filter()

tubes = vtki.MultiBlock([c1, c2])
merged = tubes.combine()
merged.plot(show_edges=True)

```

 ![download](https://discourse.vtk.org/uploads/default/original/1X/2310d324c3d42d197b4667167fe81687ba655efa.png)

Apply the filter

```python
# Get the intersection:
alg = vtk.vtkBooleanOperationPolyDataFilter()
alg.SetInputData(0, c1)
alg.SetInputData(1, c2)
alg.SetOperationToIntersection()
alg.Update()
intersection = vtki.wrap(alg.GetOutput())
alg.SetOperationToUnion()
alg.Update()
union = vtki.wrap(alg.GetOutput())

```

And plot up the result:

```python
p = vtki.Plotter()
p.add_mesh(union, opacity=0.75, color='w')
p.add_mesh(intersection, color='r')
p.show()

```

 ![download](https://discourse.vtk.org/uploads/default/original/1X/8cadeef55165c90f0bfca0e301faedc97c166127.png)

---

_[View the full topic](https://discourse.vtk.org/t/how-to-extract-surface-from-polydata/321)._
