pyvista.CompositePolyDataMapper.block_attr

pyvista.CompositePolyDataMapper.block_attr#

property CompositePolyDataMapper.block_attr: CompositeAttributes[source]#

Return the block attributes.

Notes

block_attr 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]

Examples

Add a sphere and a cube as a multiblock dataset to a plotter and then change the visibility and color of the blocks.

>>> 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-CompositePolyDataMapper-block_attr-1_00_00.png