pyvista.DataSetFilters.extract_cells

pyvista.DataSetFilters.extract_cells#

DataSetFilters.extract_cells(
ind: int | VectorLike[int],
invert: bool = False,
pass_cell_ids: bool = True,
pass_point_ids: bool = True,
progress_bar: bool = 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.

pass_point_idsbool, default: True

Add a point array 'vtkOriginalPointIds' that identifies the original points the extracted points correspond to.

Added in version 0.47.

pass_cell_idsbool, default: True

Add a cell array 'vtkOriginalCellIds' that identifies the original cells the extracted cells correspond to.

Added in version 0.47.

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()
../../../_images/pyvista-DataSetFilters-extract_cells-9b91e5b42e33a981_00_00.png