pyvista.DataSetFilters.extract_cells#

DataSetFilters.extract_cells(ind, invert=False, progress_bar=False)[source]#

Return a subset of the grid.

Parameters:
indsequence[int]

Numpy array of cell indices to be extracted.

invertbool, default: False

Invert the selection.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.UnstructuredGrid

Subselected grid.

Examples

>>> import pyvista as pv
>>> from pyvista import examples
>>> grid = pv.read(examples.hexbeamfile)
>>> subset = grid.extract_cells(range(20))
>>> subset.n_cells
20
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(
...     grid, style='wireframe', line_width=5, color='black'
... )
>>> actor = pl.add_mesh(subset, color='grey')
>>> pl.show()
https://d33wubrfki0l68.cloudfront.net/ff2d9bfdc0e43fb7c323b33ffb3e5217b69dd576/33fbd/_images/pyvista-datasetfilters-extract_cells-1_00_00.png