.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/BasicShapes/platonic_solids.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_BasicShapes_platonic_solids.py: Platonic solids =============== Read the five Platonic solids from Wavefront ``.obj`` files with :func:`microgen.shape.polyhedron.read_obj` and build them as :class:`microgen.Polyhedron` shapes. Requires the CAD backend: ``pip install microgen[cad]``. .. GENERATED FROM PYTHON SOURCE LINES 11-36 .. code-block:: Python import pyvista as pv import microgen from microgen.cad import make_compound filenames = [ "tetrahedron.obj", "cube.obj", "octahedron.obj", "dodecahedron.obj", "icosahedron.obj", ] platon_solids = [] for i, filename in enumerate(filenames): dic = microgen.shape.polyhedron.read_obj(filename) solid = microgen.shape.polyhedron.Polyhedron(dic=dic) shape = solid.generate_cad() shape = shape.translate((-6 + 3 * i, 0, 0)) platon_solids.append(shape) stl_file = "platonic_solids.stl" make_compound(platon_solids).export_stl(stl_file) .. GENERATED FROM PYTHON SOURCE LINES 37-38 .. code-block:: Python pv.read(stl_file).plot(show_edges=True, color="#ef7d2d") .. tab-set:: .. tab-item:: Static Scene .. image-sg:: /examples/BasicShapes/images/sphx_glr_platonic_solids_001.png :alt: platonic solids :srcset: /examples/BasicShapes/images/sphx_glr_platonic_solids_001.png :class: sphx-glr-single-img .. tab-item:: Interactive Scene .. offlineviewer:: /home/runner/work/microgen/microgen/docs/examples/BasicShapes/images/sphx_glr_platonic_solids_001.vtksz .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.959 seconds) .. _sphx_glr_download_examples_BasicShapes_platonic_solids.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: platonic_solids.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: platonic_solids.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: platonic_solids.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_