.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/feature_demo/show_stl.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__gallery_feature_demo_show_stl.py: Show STL File via gfx.show ========================== Demonstrates show utility with an STL file .. GENERATED FROM PYTHON SOURCE LINES 9-16 .. warning:: An external model is needed to run this example. To run this example, you need a model from the source repo's example folder. If you are running this example from a local copy of the code (dev install) no further actions are needed. Otherwise, you may have to replace the path below to point to the location of the model. .. GENERATED FROM PYTHON SOURCE LINES 16-28 .. code-block:: default import os from pathlib import Path try: # modify this line if your model is located elsewhere model_dir = Path(__file__).parents[1] / "data" except NameError: # compatibility with sphinx-gallery model_dir = Path(os.getcwd()).parent / "data" .. GENERATED FROM PYTHON SOURCE LINES 29-30 Once the path is set correctly, you can use the model as follows: .. GENERATED FROM PYTHON SOURCE LINES 30-40 .. code-block:: default import pygfx as gfx mesh = gfx.load_mesh(model_dir / "teapot.stl") if __name__ == "__main__": disp = gfx.Display() disp.show(mesh, up=(0, 0, 1)) .. image-sg:: /_gallery/feature_demo/images/sphx_glr_show_stl_001.png :alt: show stl :srcset: /_gallery/feature_demo/images/sphx_glr_show_stl_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.268 seconds) .. _sphx_glr_download__gallery_feature_demo_show_stl.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: show_stl.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: show_stl.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_