# Get intersection of PolyData line and a plane

**URL:** https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894
**Category:** Support
**Created:** [July 31, 2020, 6:48pm UTC](https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894 "2020-07-31T18:48:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jrwrigh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jrwrigh/32/2160_2.png) [@jrwrigh](https://discourse.vtk.org/u/jrwrigh)
#### Post date: [July 31, 2020, 6:48pm UTC](https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894/1 "2020-07-31T18:48:16Z")

</div>

I have a PolyLine and I’d like to get the data from that line that intersects a plane. How would I do that in Python.

I’ve tried using vtkClipPolyData and vtkCutter to no avail; the output is empty.

I’m also working in Python for this and the PolyData is wrapped in pyvista’s PolyData object type.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [July 31, 2020, 7:14pm UTC](https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894/2 "2020-07-31T19:14:45Z")

</div>

vtkCutter should work. Could you provide a full example that reproduces the issue that uses only VTK?

---

<div class="post-metadata">

### Author: ![jrwrigh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jrwrigh/32/2160_2.png) [@jrwrigh](https://discourse.vtk.org/u/jrwrigh)
#### Post date: [August 1, 2020, 2:13pm UTC](https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894/3 "2020-08-01T14:13:24Z")

</div>

Sorry for the long delay, here’s approximately the code I was using:

```python
vplane = vtk.vtkPlane()
vplane.SetOrigin((-0.4, 0, 0))
vplane.SetNormal((1,0,0))

cutter = vtk.vtkCutter()
cutter.SetCutFunction(vplane)
cutter.SetInputData(walledgePolySample)
cutter.Update()
cutterout = cutter.GetOutputDataObject(0) 

type(cutterout) # vtkCommonDataModelPython.vtkPolyData
cutterout.GetNumberOfVerts() # 0

```

Note that the `walledgePolySample` is a line planar in XY and goes from x={-0.54, -0.31}, y={0,0}.

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [August 3, 2020, 4:31am UTC](https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894/4 "2020-08-03T04:31:02Z")

</div>

It works well for me:

```python
line = vtk.vtkLineSource()
line.SetPoint1(-0.54, 0, 0)
line.SetPoint2(-0.31, 0, 0)
line.Update()

vplane = vtk.vtkPlane()
vplane.SetOrigin(-0.4, 0, 0)
vplane.SetNormal(1,0,0)

cutter = vtk.vtkCutter()
cutter.SetCutFunction(vplane)
cutter.SetInputData(line.GetOutput())
cutter.Update()
cutterout = cutter.GetOutput()

print(cutterout.GetNumberOfPoints())
print(cutterout.GetPoint(0))

```

Provides this output:

```auto
1
(-0.4000000059604645, 0.0, 0.0)

```

---

<div class="post-metadata">

### Author: ![jrwrigh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jrwrigh/32/2160_2.png) [@jrwrigh](https://discourse.vtk.org/u/jrwrigh)
#### Post date: [August 4, 2020, 3:53pm UTC](https://discourse.vtk.org/t/get-intersection-of-polydata-line-and-a-plane/3894/5 "2020-08-04T15:53:55Z")

</div>

Yep, that worked! Thanks!

If anyone is using pyvista, the only change is to do:

```auto
- cutter.SetInputData(line.GetOutput())
+ cutter.SetInputData(line)

```

where line is a pyvista PolyData object.
