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.
- validatebool |
MeshValidationFields| sequence[MeshValidationFields], default:False Validate the mesh using
validate_mesh()after initialization. Set this toTrueto validate all fields, or specify any combination of fields allowed byvalidate_mesh.Added in version 0.47.
- **kwargs
dict,optional See
pyvista.read()for additional options.
- *args
Examples#
Download Python source code | Download Jupyter notebook
>>> 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.
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(algorithm=None)
Used In#
Guides
- Composite Datasets (2 uses)
Docstring Examples
BlockAttributes(1 use)BlockAttributes.color(1 use)BlockAttributes.opacity(1 use)BlockAttributes.pickable(1 use)BlockAttributes.visible(1 use)48 more
CompositeAttributes(1 use)CompositeAttributes.get_block(1 use)CompositeAttributes.reset_colors(1 use)CompositeAttributes.reset_opacities(1 use)CompositeAttributes.reset_pickabilities(1 use)CompositeAttributes.reset_visibilities(1 use)CompositeFilters.combine(1 use)CompositeFilters.generic_filter(1 use)CompositePolyDataMapper.block_attr(1 use)CompositePolyDataMapper.color_missing_with_nan(1 use)CompositePolyDataMapper.dataset(1 use)CompositePolyDataMapper.set_unique_colors(1 use)DataObject.add_field_data(1 use)DataObjectFilters.convex_hull(1 use)MultiBlock.append(1 use)MultiBlock.bounds(1 use)MultiBlock.center(1 use)MultiBlock.clean(1 use)MultiBlock.copy(1 use)MultiBlock.extend(1 use)MultiBlock.flatten(1 use)MultiBlock.get(1 use)MultiBlock.get_block(1 use)MultiBlock.get_block_name(1 use)MultiBlock.get_index_by_name(1 use)MultiBlock.insert(1 use)MultiBlock.is_empty(1 use)MultiBlock.is_nested(1 use)MultiBlock.keys(1 use)MultiBlock.length(1 use)MultiBlock.move_nested_field_data_to_root(1 use)MultiBlock.n_blocks(1 use)MultiBlock.pop(1 use)MultiBlock.replace(1 use)MultiBlock.reverse(1 use)MultiBlock.set_block_name(1 use)MultiBlock.volume(1 use)PickingComponent.enable_block_picking(1 use)Plotter.add_composite(1 use)Plotter.enable_block_picking(1 use)_BaseMapper.interpolate_before_map(1 use)_BaseMapper.lookup_table(1 use)_BaseMapper.scalar_map_mode(1 use)_BaseMapper.scalar_range(1 use)_BaseMapper.scalar_visibility(1 use)download_coil_magnetic_field(1 use)download_doorman(1 use)plot_compare(1 use)
Gallery Examples
Inheritance#
Inherited members are documented on _BoundsSizeMixin, CompositeFilters, DataObjectFilters, DataObject.
See them all under Inherited Attributes, Inherited Methods and Filters.
Wraps vtkMultiBlockDataSet.
Attributes#
Return a set of all block types. |
|
Find min/max for bounds across blocks. |
|
Set or 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 types. |
|
Return the total volume of all meshes in this dataset. |
Inherited Attributes#
Return the actual size of the dataset object. |
|
Return the size of each axis of the object’s bounding box. |
|
Return FieldData as DataSetAttributes. |
|
Get address of the underlying VTK C++ object. |
|
Set or return a user-specified data dictionary. |
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. |
Inherited Methods#
Add field data. |
|
Convert this |
|
Remove all field data. |
|
Copy the data attributes of the input dataset object. |
|
Copy the structure (geometry and topology) of the input dataset object. |
|
Return the header stats of this dataset. |
|
Save this vtk object to file. |
Filters#
Generate points at the center of the cells in this dataset. |
|
Transform cell data into point data. |
|
Compute a function of (geometric) quality for each cell of a mesh. |
|
Check the validity of each cell in this dataset. |
|
Clip a dataset by a plane by specifying the origin and normal. |
|
Clip a dataset by a bounding box defined by the bounds. |
|
Clip a dataset by a slab of finite thickness around a plane. |
|
Combine all blocks into a single unstructured grid. |
|
Compute sizes for 0D (vertex count), 1D (length), 2D (area) and 3D (volume) cells. |
|
Compute the convex hull from this mesh’s points. |
|
Transform cell data into point data. |
|
Generate scalar values on a dataset. |
|
Extract all the internal/external edges of the dataset as PolyData. |
|
Extract the surface the geometry of all blocks. |
|
Extract surface geometry of the mesh as |
|
Flip mesh about the normal. |
|
Flip mesh about the x-axis. |
|
Flip mesh about the y-axis. |
|
Flip mesh about the z-axis. |
|
Apply any filter to all nested blocks recursively. |
|
Produce an outline of the full extent for the all blocks in this composite dataset. |
|
Produce an outline of the corners for the all blocks in this composite dataset. |
|
Transform point data into cell data. |
|
Transform point data into cell data. |
|
Reflect a dataset across a plane. |
|
Resize the dataset’s bounds. |
|
Rotate mesh about a point with a rotation matrix or |
|
Rotate mesh about a vector. |
|
Rotate mesh about the x-axis. |
|
Rotate mesh about the y-axis. |
|
Rotate mesh about the z-axis. |
|
Resample array data from a passed mesh onto this mesh. |
|
Scale the mesh. |
|
Slice a dataset by a plane at the specified origin and normal vector orientation. |
|
Create many slices of the input dataset along a specified axis. |
|
Slice a dataset using a polyline/spline as the path. |
|
Slice a dataset by a VTK implicit function. |
|
Create three orthogonal slices through the dataset on the three Cartesian planes. |
|
Transform this mesh with a 4x4 transform. |
|
Translate the mesh. |
|
Return an all triangle mesh. |
|
Validate this mesh’s array data, points, and cells. |