pyvista.MultiBlock.get

Contents

pyvista.MultiBlock.get#

MultiBlock.get(
index: str,
default: MultiBlock | DataSet | None = None,
) MultiBlock | DataSet | None[source]#

Get a block by its name.

If the name is non-unique then returns the first occurrence. Returns default if name isn’t in the dataset.

Parameters:
indexstr

Index or name of the dataset within the multiblock.

defaultpyvista.DataSet or pyvista.MultiBlock, optional

Default to return if index is not in the multiblock.

Returns:
pyvista.DataSet or pyvista.MultiBlock or None

Dataset from the given index if it exists.

Examples

>>> import pyvista as pv
>>> from pyvista import examples
>>> data = {"poly": pv.PolyData(), "img": pv.ImageData()}
>>> blocks = pv.MultiBlock(data)
>>> blocks.get("poly")
PolyData ...
>>> blocks.get("cone")