.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-basic-pyvista-examples/tree_struct.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_00-basic-pyvista-examples_tree_struct.py: .. _ref_tree_struct: ============================= MeshObjectPlot tree structure ============================= This example shows how to add a tree structure of MeshObjectPlot to the plotter. .. GENERATED FROM PYTHON SOURCE LINES 32-76 .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/00-basic-pyvista-examples/images/sphx_glr_tree_struct_001.png :alt: tree struct :srcset: /examples/00-basic-pyvista-examples/images/sphx_glr_tree_struct_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/ansys-tools-visualization-interface/ansys-tools-visualization-interface/doc/source/examples/00-basic-pyvista-examples/images/sphx_glr_tree_struct_001.vtksz .. rst-class:: sphx-glr-script-out .. code-block:: none [] | .. code-block:: Python 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() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.363 seconds) .. _sphx_glr_download_examples_00-basic-pyvista-examples_tree_struct.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: tree_struct.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: tree_struct.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: tree_struct.zip `