pyvista.MultiBlock.replace#
- MultiBlock.replace(
- index: int,
- dataset: MultiBlock | DataSet | None,
Replace dataset at index while preserving key name.
- Parameters:
- index
int
Index of the block to replace.
- dataset
pyvista.DataSet
orpyvista.MultiBlock
Dataset for replacing the one at index.
- 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