pyvista.BlockAttributes#

class BlockAttributes(block, attr)[source]#

Block attributes used to set the attributes of a block.

Parameters:
blockpyvista.DataObject

PyVista data object.

attrpyvista.plotting.composite_mapper.CompositeAttributes

Parent attributes.

Notes

This class employs VTK’s flat indexing and allows for accessing both the blocks of a composite dataset as well as the entire composite dataset. If there is only one composite dataset, A, which contains datasets [b, c], the indexing would be [A, b, c].

If there are two composite datasets [B, C] in one composite dataset, A, each of which containing three additional datasets [d, e, f], and [g, h, i], respectively, then the head node, A, would be the zero index, followed by the first child, B, followed by all the children of B, [d, e, f]. In data structures, this flat indexing would be known as “Depth-first search” and the entire indexing would be:

[A, B, d, e, f, C, g, h, i]

Note how the composite datasets themselves are capitalized and are accessible in the flat indexing, and not just the datasets.

Examples

Add a sphere and a cube as a multiblock dataset to a plotter and then change the visibility and color of the blocks. Note how the index of the cube is 1 as the index of the entire multiblock is 0.

>>> import pyvista as pv
>>> dataset = pv.MultiBlock([pv.Cube(), pv.Sphere(center=(0, 0, 1))])
>>> pl = pv.Plotter()
>>> actor, mapper = pl.add_composite(dataset)
>>> mapper.block_attr[1].color = 'b'
>>> mapper.block_attr[1].opacity = 0.1
>>> mapper.block_attr[1]
Composite Block Addr=... Attributes
Visible:   None
Opacity:   0.1
Color:     Color(name='blue', hex='#0000ffff', opacity=255)
Pickable   None
../../../_images/pyvista-BlockAttributes-1_00_00.png

Methods

Attributes

BlockAttributes.color

Get or set the color of a block.

BlockAttributes.opacity

Get or set the opacity of a block.

BlockAttributes.pickable

Get or set the pickability of a block.

BlockAttributes.visible

Get or set the visibility of a block.