.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/02-basic-usd-examples/plain_usage.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_02-basic-usd-examples_plain_usage.py: .. _ref_plain_usage_usd: ============================== Plain usage of the USD backend ============================== This example shows how to use the Python USD viewer backend in the Visualization Interface Tool to display meshes using the OpenUSD-based viewer from the ``python-usd-viewer`` package. .. GENERATED FROM PYTHON SOURCE LINES 35-56 Plot a single mesh ================== This code shows how to plot a single PyVista mesh with the USD backend. .. code-block:: python import pyvista as pv from ansys.tools.visualization_interface import Plotter from ansys.tools.visualization_interface.backends.usd.usd_interface import USDInterface mesh = pv.Sphere() # Create a plotter with the USD backend pl = Plotter(backend=USDInterface()) # Add the mesh to the plotter pl.plot(mesh) # Show the plotter — opens a Qt window and blocks until it is closed pl.show() .. GENERATED FROM PYTHON SOURCE LINES 59-79 Plot multiple meshes ==================== Use :meth:`plot_iter` to add several meshes at once before showing the viewer. .. code-block:: python import pyvista as pv from ansys.tools.visualization_interface import Plotter from ansys.tools.visualization_interface.backends.usd.usd_interface import USDInterface meshes = [ pv.Sphere(center=(0, 0, 0)), pv.Cube(center=(2, 0, 0)), pv.Cylinder(center=(-2, 0, 0)), ] pl = Plotter(backend=USDInterface()) pl.plot_iter(meshes) pl.show() .. GENERATED FROM PYTHON SOURCE LINES 82-114 Load and display a USD file =========================== If you already have a ``.usd`` / ``.usda`` / ``.usdc`` file on disk, pass its path directly to :meth:`plot`. The file is opened as a :class:`pxr.Usd.Stage` and displayed in the viewer. .. code-block:: python import pyvista as pv import tempfile, os from ansys.tools.visualization_interface import Plotter from ansys.tools.visualization_interface.backends.usd.usd_interface import USDInterface # Write a simple USD file to a temporary location for demonstration purposes usd_content = """\ #usda 1.0 def Sphere "Ball" { double radius = 1 } """ tmp = tempfile.NamedTemporaryFile(suffix=".usda", mode="w", delete=False) tmp.write(usd_content) tmp.close() pl = Plotter(backend=USDInterface()) pl.plot(tmp.name) pl.show() os.unlink(tmp.name) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_examples_02-basic-usd-examples_plain_usage.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plain_usage.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plain_usage.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plain_usage.zip `