.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/01-basic-plotly-examples/name-filter.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_01-basic-plotly-examples_name-filter.py: .. _ref_name_filter_plotly: ==================================== Name filtering in the Plotly backend ==================================== The ``name_filter`` parameter accepts a regular-expression string and is available on :meth:`Plotter.plot`, :meth:`Plotter.plot_iter`, and :meth:`Plotter.show`. Only :class:`MeshObjectPlot` objects whose ``name`` matches the pattern are added to the figure; everything else is silently skipped. .. GENERATED FROM PYTHON SOURCE LINES 35-50 .. code-block:: Python import pyvista as pv from ansys.tools.visualization_interface import Plotter from ansys.tools.visualization_interface.backends.plotly.plotly_interface import PlotlyBackend from ansys.tools.visualization_interface.types.mesh_object_plot import MeshObjectPlot class Part: """Minimal domain object with a name.""" def __init__(self, name: str): self.name = name .. GENERATED FROM PYTHON SOURCE LINES 51-53 Build a set of named parts ========================== .. GENERATED FROM PYTHON SOURCE LINES 53-62 .. code-block:: Python parts = [ MeshObjectPlot(Part("Wheel_FL"), pv.Sphere(center=(-1, 1, 0), radius=0.3)), MeshObjectPlot(Part("Wheel_FR"), pv.Sphere(center=( 1, 1, 0), radius=0.3)), MeshObjectPlot(Part("Wheel_RL"), pv.Sphere(center=(-1, -1, 0), radius=0.3)), MeshObjectPlot(Part("Wheel_RR"), pv.Sphere(center=( 1, -1, 0), radius=0.3)), MeshObjectPlot(Part("Chassis"), pv.Box(bounds=(-0.8, 0.8, -1.2, 1.2, 0, 0.4))), ] .. GENERATED FROM PYTHON SOURCE LINES 63-68 Show with ``name_filter`` via ``show()`` ======================================== Pass ``name_filter`` directly to :meth:`Plotter.show` together with the list of objects. The filter is applied while plotting, so only matching parts are added to the figure. .. GENERATED FROM PYTHON SOURCE LINES 68-73 .. code-block:: Python pl = Plotter(backend=PlotlyBackend()) pl.show(plottable_object=parts) pl = Plotter(backend=PlotlyBackend()) pl.show(plottable_object=parts, name_filter="Wheel") .. raw:: html


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.036 seconds) .. _sphx_glr_download_examples_01-basic-plotly-examples_name-filter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: name-filter.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: name-filter.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: name-filter.zip `