pyvista.MultiBlock.get_block

pyvista.MultiBlock.get_block#

MultiBlock.get_block(
index: int | Sequence[int] | str,
) MultiBlock | DataSet | None[source]#

Get a block by its index or name.

If the name is non-unique then returns the first occurrence. This method is similar to using [] for indexing except this method also supports indexing nested blocks.

Added in version 0.45.

Parameters:
indexint | Sequence[int] | str

Index or name of the dataset within the multiblock. Specify a sequence of indices to replace a nested block.

Returns:
pyvista.DataSet or pyvista.MultiBlock or None

Dataset from the given index if it exists.

See also

get

Get a block and return a default value instead of raising an IndexError.

Examples

>>> import pyvista as pv
>>> blocks = pv.MultiBlock([pv.PolyData(), pv.ImageData()])
>>> nested = pv.MultiBlock([blocks])
>>> nested.get_block(0)
MultiBlock ...
>>> nested.get_block((0, 1))
ImageData ...