PyVistaInterface#

class ansys.tools.visualization_interface.backends.pyvista.pyvista_interface.PyVistaInterface(scene: pyvista.Plotter | None = None, color_opts: Dict | None = None, num_points: int = 100, enable_widgets: bool = True, show_plane: bool = False, **plotter_kwargs)#

Provides the middle class between PyVista plotting operations and PyAnsys objects.

The main purpose of this class is to simplify interaction between PyVista and the PyVista backend provided. This class is responsible for creating the PyVista scene and adding the PyAnsys objects to it.

Parameters:
scenePlotter, default: None

Scene for rendering the objects. If passed, off_screen needs to be set manually beforehand for documentation and testing.

color_optsdict, default: None

Dictionary containing the background and top colors.

num_pointsint, default: 100

Number of points to use to render the shapes.

enable_widgetsbool, default: True

Whether to enable widget buttons in the plotter window. Widget buttons must be disabled when using trame for visualization.

show_planebool, default: False

Whether to show the XY plane in the plotter window.

Overview#

view_xy

View the scene from the XY plane.

view_xz

View the scene from the XZ plane.

view_yx

View the scene from the YX plane.

view_yz

View the scene from the YZ plane.

view_zx

View the scene from the ZX plane.

view_zy

View the scene from the ZY plane.

clip

Clip a given mesh with a plane.

plot_meshobject

Plot a generic MeshObjectPlot object to the scene.

plot_edges

Plot the outer edges of an object to the plot.

plot

Plot any type of object to the scene.

plot_iter

Plot elements of an iterable of any type of objects to the scene.

show

Show the rendered scene on the screen.

set_add_mesh_defaults

Set the default values for the plotting options.

scene

Rendered scene object.

object_to_actors_map

Mapping between the PyVista actor and the PyAnsys objects.

Import detail#

from ansys.tools.visualization_interface.backends.pyvista.pyvista_interface import PyVistaInterface

Property detail#

property PyVistaInterface.scene: pyvista.plotting.plotter.Plotter#

Rendered scene object.

Returns:
Plotter

Rendered scene object.

property PyVistaInterface.object_to_actors_map: Dict[pyvista.Actor, ansys.tools.visualization_interface.types.mesh_object_plot.MeshObjectPlot]#

Mapping between the PyVista actor and the PyAnsys objects.

Method detail#

PyVistaInterface.view_xy() None#

View the scene from the XY plane.

PyVistaInterface.view_xz() None#

View the scene from the XZ plane.

PyVistaInterface.view_yx() None#

View the scene from the YX plane.

PyVistaInterface.view_yz() None#

View the scene from the YZ plane.

PyVistaInterface.view_zx() None#

View the scene from the ZX plane.

PyVistaInterface.view_zy() None#

View the scene from the ZY plane.

PyVistaInterface.clip(mesh: pyvista.PolyData | pyvista.MultiBlock | pyvista.UnstructuredGrid, plane: ansys.tools.visualization_interface.utils.clip_plane.ClipPlane) pyvista.PolyData | pyvista.MultiBlock#

Clip a given mesh with a plane.

Parameters:
meshUnion[pv.PolyData, pv.MultiBlock]

Mesh.

normalstr, default: “x”

Plane to use for clipping. Options are "x", "-x", "y", "-y", "z", and "-z".

origintuple, default: None

Origin point of the plane.

planeClipPlane, default: None

Clipping plane to cut the mesh with.

Returns:
Union[pv.PolyData,pv.MultiBlock]

Clipped mesh.

PyVistaInterface.plot_meshobject(custom_object: ansys.tools.visualization_interface.types.mesh_object_plot.MeshObjectPlot, **plotting_options)#

Plot a generic MeshObjectPlot object to the scene.

Parameters:
plottable_objectMeshObjectPlot

Object to add to the scene.

**plotting_optionsdict, default: None

Keyword arguments. For allowable keyword arguments, see the Plotter.add_mesh method.

PyVistaInterface.plot_edges(custom_object: ansys.tools.visualization_interface.types.mesh_object_plot.MeshObjectPlot, **plotting_options) None#

Plot the outer edges of an object to the plot.

This method has the side effect of adding the edges to the MeshObjectPlot object that you pass through the parameters.

Parameters:
custom_objectMeshObjectPlot

Custom object with the edges to add.

**plotting_optionsdict, default: None

Keyword arguments. For allowable keyword arguments, see the Plotter.add_mesh method.

PyVistaInterface.plot(plottable_object: pyvista.PolyData | pyvista.MultiBlock | ansys.tools.visualization_interface.types.mesh_object_plot.MeshObjectPlot | pyvista.UnstructuredGrid, name_filter: str = None, **plotting_options) None#

Plot any type of object to the scene.

Supported object types are List[pv.PolyData], MeshObjectPlot, and pv.MultiBlock.

Parameters:
plottable_objectUnion[pv.PolyData, pv.MultiBlock, MeshObjectPlot, pv.UnstructuredGrid, pv.StructuredGrid]

Object to plot.

name_filterstr, default: None

Regular expression with the desired name or names to include in the plotter.

**plotting_optionsdict, default: None

Keyword arguments. For allowable keyword arguments, see the Plotter.add_mesh method.

PyVistaInterface.plot_iter(plotting_list: List[Any], name_filter: str = None, **plotting_options) None#

Plot elements of an iterable of any type of objects to the scene.

Parameters:
plotting_listList[Any]

List of objects to plot.

name_filterstr, default: None

Regular expression with the desired name or names to include in the plotter.

**plotting_optionsdict, default: None

Keyword arguments. For allowable keyword arguments, see the Plotter.add_mesh method.

PyVistaInterface.show(show_plane: bool = False, jupyter_backend: str | None = None, **kwargs: Dict | None) None#

Show the rendered scene on the screen.

Parameters:
show_planebool, default: True

Whether to show the XY plane.

jupyter_backendstr, default: None

PyVista Jupyter backend.

**kwargsdict, default: None

Plotting keyword arguments. For allowable keyword arguments, see the Plotter.show method.

Notes

For more information on supported Jupyter backends, see Jupyter Notebook Plotting in the PyVista documentation.

PyVistaInterface.set_add_mesh_defaults(plotting_options: Dict | None) None#

Set the default values for the plotting options.

Parameters:
plotting_optionsOptional[Dict]

Keyword arguments. For allowable keyword arguments, see the Plotter.add_mesh method.