pyvista.MultiBlock.insert#

MultiBlock.insert(
index: int,
dataset: MultiBlock | DataSet,
name: str | None = None,
) None[source]#

Insert data before index.

Parameters:
indexint

Index before which to insert data.

datasetpyvista.DataSet or pyvista.MultiBlock

Data to insert.

namestr, optional

Name for key to give dataset. A default name is given depending on the block index as 'Block-{i:02}'.

Examples

Insert a new pyvista.PolyData at the start of the multiblock.

>>> import pyvista as pv
>>> data = {
...     "cube": pv.Cube(),
...     "sphere": pv.Sphere(center=(2, 2, 0)),
... }
>>> blocks = pv.MultiBlock(data)
>>> blocks.keys()
['cube', 'sphere']
>>> blocks.insert(0, pv.Plane(), "plane")
>>> blocks.keys()
['plane', 'cube', 'sphere']