pyvista.BlockAttributes.opacity#

property BlockAttributes.opacity: float | None[source]#

Get or set the opacity of a block.

If opacity has not been set this will be None.

Warning

VTK 9.0.3 has a bug where changing the opacity to less than 1.0 also changes the edge visibility on the block that is partially transparent.

Examples

Change the opacity of the second block of the dataset.

Note how the zero index is the entire multiblock, so we have to add 1 to our indexing to access the right block.

>>> 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[2].opacity = 0.5
>>> pl.show()
../../../_images/pyvista-BlockAttributes-opacity-1_00_00.png