pyvista.MultiBlock.replace#

MultiBlock.replace(
index: int,
dataset: MultiBlock | DataSet | None,
) None[source]#

Replace dataset at index while preserving key name.

Parameters:
indexint

Index of the block to replace.

datasetpyvista.DataSet or pyvista.MultiBlock

Dataset for replacing the one at index.

Examples

>>> import pyvista as pv
>>> import numpy as np
>>> data = {
...     "cube": pv.Cube(),
...     "sphere": pv.Sphere(center=(2, 2, 0)),
... }
>>> blocks = pv.MultiBlock(data)
>>> blocks.replace(1, pv.Sphere(center=(10, 10, 10)))
>>> blocks.keys()
['cube', 'sphere']
>>> np.allclose(blocks[1].center, [10.0, 10.0, 10.0])
True