# index array or boolean array from vtkSelection

**URL:** https://discourse.vtk.org/t/index-array-or-boolean-array-from-vtkselection/8495
**Category:** Support
**Tags:** python
**Created:** [May 15, 2022, 1:29pm UTC](https://discourse.vtk.org/t/index-array-or-boolean-array-from-vtkselection/8495 "2022-05-15T13:29:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Kiordestruk\_k](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kiordestruk_k/32/3317_2.png) [@Kiordestruk\_k](https://discourse.vtk.org/u/Kiordestruk_k)
#### Post date: [May 15, 2022, 1:29pm UTC](https://discourse.vtk.org/t/index-array-or-boolean-array-from-vtkselection/8495/1 "2022-05-15T13:29:52Z")

</div>

Hello, I would like to get a numpy array of integer indices or a numpy boolean mask from a vtkSelection object in Python :

```auto
def get_visible_vertices(plotter, pv_mesh):
    # perfrom the automatic picking
    selector = vtk.vtkOpenGLHardwareSelector()
    selector.SetFieldAssociation(vtk.vtkDataObject.FIELD_ASSOCIATION_POINTS)
    selector.SetRenderer(plotter.renderer)
    selector.SetArea(0,0,plotter.window_size[0],plotter.window_size[1])
    selection = selector.Select()
    # mask = selection.ExtractBooleanMask() <- How to do this ?
    # vertex_indices = selection.ExtractVertexIndices() <- or this ?

```

`plotter` is a an object from Pyvista which is a wrapper around vtk render as far as I understand. `pv_mesh` is a `PolyData` from Pyvista which should be a wrapper around vtk’s `PolyData`

The c++ documentation seems overwhelming to me I do not know where to start, sorry.

Thanks

PS : I know that the vtkSelection I get is “correct” because I can plot it with the following code :

```auto
    extractor = vtk.vtkExtractSelection()
    extractor.SetInputData(0, pv_mesh)
    extractor.SetInputData(1, selection)
    extractor.Update()
    pv.wrap(extractor.GetOutput()).plot()

```

And i get this plot which is coherent (the red drawings represents the camera when selecting the visible vertices):  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/f97628f75a4acb1beeadf7786dd295e7483f183c.png)  
 ![image](https://discourse.vtk.org/uploads/default/original/2X/a/ae7d447cb0c64ecdeb82b38345e72e6643c91cfc.png)
