.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/00-basic-pyvista-examples/using_meshobject.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_using_meshobject.py: .. _ref_using_meshobject: ================================ Use the ``MeshObjectPlot`` class ================================ The Visualization Interface Tool provides the ``MeshObject`` helper class to relate a custom object with its mesh. With a custom object, you can take advantage of the full potential of the Visualization Interface Tool. This example shows how to use the ``MeshObjectPlot`` class to plot your custom objects. .. GENERATED FROM PYTHON SOURCE LINES 38-40 Relate ``CustomObject`` class with a PyVista mesh ================================================= .. GENERATED FROM PYTHON SOURCE LINES 40-61 .. code-block:: Python import pyvista as pv # Note that the ``CustomObject`` class must have a way to get the mesh # and a name or ID. class CustomObject: def __init__(self): self.name = "CustomObject" self.mesh = pv.Cube() def get_mesh(self): return self.mesh def name(self): return self.name # Create a custom object custom_object = CustomObject() .. GENERATED FROM PYTHON SOURCE LINES 62-64 Create a ``MeshObjectPlot`` instance ==================================== .. GENERATED FROM PYTHON SOURCE LINES 64-71 .. code-block:: Python from ansys.tools.visualization_interface import MeshObjectPlot # Create an instance mesh_object = MeshObjectPlot(custom_object, custom_object.get_mesh()) .. GENERATED FROM PYTHON SOURCE LINES 72-74 Plot the ``MeshObjectPlot`` instance ==================================== .. GENERATED FROM PYTHON SOURCE LINES 74-80 .. code-block:: Python from ansys.tools.visualization_interface import Plotter pl = Plotter() pl.plot(mesh_object) pl.show() .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/00-basic-pyvista-examples/images/sphx_glr_using_meshobject_001.png :alt: using meshobject :srcset: /examples/00-basic-pyvista-examples/images/sphx_glr_using_meshobject_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_using_meshobject_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.443 seconds) .. _sphx_glr_download_examples_00-basic-pyvista-examples_using_meshobject.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: using_meshobject.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: using_meshobject.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: using_meshobject.zip `