Note
Go to the end to download the full example code.
MeshObjectPlot tree structure#
This example shows how to add a tree structure of MeshObjectPlot to the plotter.

[]
import pyvista as pv
from ansys.tools.visualization_interface import Plotter
class CustomObject:
def __init__(self):
self.name = "CustomObject"
self.mesh = pv.Cube(center=(1, 1, 0))
def get_mesh(self):
return self.mesh
def name(self):
return self.name
# Create a custom objects
custom_cube = CustomObject()
custom_cube.name = "CustomCube"
custom_sphere = CustomObject()
custom_sphere.mesh = pv.Sphere(center=(0, 0, 5))
custom_sphere.name = "CustomSphere"
custom_sphere1 = CustomObject()
custom_sphere1.mesh = pv.Sphere(center=(5, 0, 5))
custom_sphere1.name = "CustomSphere"
from ansys.tools.visualization_interface import MeshObjectPlot
# Create an instance
mesh_object_cube = MeshObjectPlot(custom_cube, custom_cube.get_mesh())
mesh_object_sphere = MeshObjectPlot(custom_sphere, custom_sphere.get_mesh())
mesh_object_sphere1 = MeshObjectPlot(custom_sphere1, custom_sphere1.get_mesh())
mesh_object_cube.add_child(mesh_object_sphere)
mesh_object_sphere.add_child(mesh_object_sphere1)
pl = Plotter()
pl.plot(mesh_object_cube, plot_children=True)
pl.backend._pl.hide_children(mesh_object_cube)
pl.show()
Total running time of the script: (0 minutes 0.363 seconds)