# How to extract the ids of the boundary points of a surface?

**URL:** https://discourse.vtk.org/t/how-to-extract-the-ids-of-the-boundary-points-of-a-surface/2530
**Category:** Support
**Created:** [February 1, 2020, 2:30am UTC](https://discourse.vtk.org/t/how-to-extract-the-ids-of-the-boundary-points-of-a-surface/2530 "2020-02-01T02:30:34Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![normanius](https://discourse.vtk.org/user_avatar/discourse.vtk.org/normanius/32/611_2.png) [@normanius](https://discourse.vtk.org/u/normanius)
#### Post date: [February 1, 2020, 7:01pm UTC](https://discourse.vtk.org/t/how-to-extract-the-ids-of-the-boundary-points-of-a-surface/2530/3 "2020-02-01T19:01:46Z")

</div>

I totally agree. Using [`vtkIdFilter`](https://vtk.org/doc/nightly/html/classvtkIdFilter.html) is the right way (it creates such a scalar array with the ids as point data). I had messed up something in my tests. The following works:

```
def extractBoundaryIds(source):
    idFilter = vtk.vtkIdFilter()
    idFilter.SetInputConnection(source.GetOutputPort())
    idFilter.SetIdsArrayName("ids")
    idFilter.SetPointIds(True)
    idFilter.SetCellIds(False)
    # Available for vtk>=8.3:
    #idFilter.SetPointIdsArrayName(arrayName)
    #idFilter.SetCellIdsArrayName(arrayName)
    idFilter.Update()

    edges = vtk.vtkFeatureEdges()
    edges.SetInputConnection(idFilter.GetOutputPort())
    edges.BoundaryEdgesOn()
    edges.ManifoldEdgesOff()
    edges.NonManifoldEdgesOff()
    edges.FeatureEdgesOff()
    edges.Update()

    array = edges.GetOutput().GetPointData().GetArray("ids")
    n = edges.GetOutput().GetNumberOfPoints()
    boundaryIds = []
    for i in range(n):
        boundaryIds.append(array.GetValue(i))
    return boundaryIds
```

---

_[View the full topic](https://discourse.vtk.org/t/how-to-extract-the-ids-of-the-boundary-points-of-a-surface/2530)._
