pyvista.MultiBlock#
- class MultiBlock(*args, **kwargs)[source]#
A composite class to hold many data sets which can be iterated over.
This wraps/extends the vtkMultiBlockDataSet class so that we can easily plot these data sets and use the composite in a Pythonic manner.
You can think of
MultiBlocklike a list as we can iterate over this data structure by index. It has some dictionary features as we can also access blocks by their string name.Changed in version 0.36.0:
MultiBlockadheres more closely to being list like, and inherits fromcollections.abc.MutableSequence. Multiple nonconforming behaviors were removed or modified.- Parameters:
- *args
dict,optional Data object dictionary.
- **kwargs
dict,optional See
pyvista.read()for additional options.
- *args
Examples
>>> import pyvista as pv
Create an empty composite dataset.
>>> blocks = pv.MultiBlock()
Add a dataset to the collection.
>>> sphere = pv.Sphere() >>> blocks.append(sphere)
Add a named block.
>>> blocks['cube'] = pv.Cube()
Instantiate from a list of objects.
>>> data = [ ... pv.Sphere(center=(2, 0, 0)), ... pv.Cube(center=(0, 2, 0)), ... pv.Cone(), ... ] >>> blocks = pv.MultiBlock(data) >>> blocks.plot()
Instantiate from a dictionary.
>>> data = { ... 'cube': pv.Cube(), ... 'sphere': pv.Sphere(center=(2, 2, 0)), ... } >>> blocks = pv.MultiBlock(data) >>> blocks.plot()
Iterate over the collection.
>>> for name in blocks.keys(): ... block = blocks[name]
>>> for block in blocks: ... # Do something with each dataset ... surf = block.extract_surface()
Methods#
|
Add a data set to the next block index. |
|
Convert all the datasets within this MultiBlock to |
Convert all the datasets within this MultiBlock to |
|
|
Remove any null blocks in place. |
Clear all cell data from all blocks. |
|
Clear all data from all blocks. |
|
Clear all point data from all blocks. |
|
|
Return a copy of the multiblock. |
|
Copy pyvista meta data onto this object from another object. |
|
Overwrite this MultiBlock with another MultiBlock as a deep copy. |
|
Extend MultiBlock with an Iterable. |
|
Flatten this |
|
Get a block by its index or name. |
|
Get a block by its index or name. |
|
Return the string name of the block at the given index. |
|
Get the min/max of an array given its name across all blocks. |
Find the index number by block name. |
|
|
Insert data before index. |
Get all the block names in the dataset. |
|
Move or copy field data from all nested |
|
|
Plot a PyVista, numpy, or vtk object. |
|
Pop off a block at the specified index. |
|
Iterate over all nested blocks recursively. |
|
Replace dataset at index while preserving key name. |
Reverse MultiBlock in-place. |
|
|
Find the scalars by name and appropriately set it as active. |
|
Set a block's string name at the specified index. |
|
Shallow copy the given multiblock to this multiblock. |
Ensure that all nested data structures are wrapped as PyVista datasets. |
Attributes#
Return a set of all block type(s). |
|
Find min/max for bounds across blocks. |
|
Return the center of the bounding box. |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return |
|
Return the length of the diagonal of the bounding box. |
|
Return the total number of blocks set. |
|
Return a set of all nested block type(s). |
|
Return the total volume of all meshes in this dataset. |
|