|
| 1 | +--- |
| 2 | +jupytext: |
| 3 | + text_representation: |
| 4 | + extension: .mystnb |
| 5 | + format_name: myst |
| 6 | + format_version: 0.13 |
| 7 | + jupytext_version: 1.14.1 |
| 8 | +kernelspec: |
| 9 | + display_name: Python 3 (ipykernel) |
| 10 | + language: python |
| 11 | + name: python3 |
| 12 | +--- |
| 13 | + |
| 14 | +# Miscellaneous: Example template |
| 15 | + |
| 16 | +This example serves as a template for creating new examples in the documentation. |
| 17 | +It shows developers how to structure their code and comments for clarity and consistency. |
| 18 | +It also provides a basic outline for importing necessary modules, initializing the modeler, |
| 19 | +performing operations, and closing the modeler. |
| 20 | + |
| 21 | +It is important to follow the conventions and formatting used in this example to ensure that |
| 22 | +the documentation is easy to read and understandable. |
| 23 | + |
| 24 | +## Example imports |
| 25 | + |
| 26 | +Perform the required imports for this example. |
| 27 | +This section should include all necessary imports for the example to run correctly. |
| 28 | + |
| 29 | +```{code-cell} ipython3 |
| 30 | +# Imports |
| 31 | +from ansys.geometry.core import launch_modeler |
| 32 | +from ansys.geometry.core.math import Point2D |
| 33 | +from ansys.geometry.core.sketch import Sketch |
| 34 | +``` |
| 35 | + |
| 36 | +## Initialize the modeler |
| 37 | + |
| 38 | +```{code-cell} ipython3 |
| 39 | +# Initialize the modeler for this example notebook |
| 40 | +m = launch_modeler() |
| 41 | +print(m) |
| 42 | +``` |
| 43 | + |
| 44 | +## Body of your example |
| 45 | + |
| 46 | +Developers can add their code here to perform the desired operations. |
| 47 | +This section should include comments and explanations to explain what the code is doing. |
| 48 | + |
| 49 | +### Example section: Initialize a design |
| 50 | + |
| 51 | +Create a design named ``example-design``. |
| 52 | + |
| 53 | +```{code-cell} ipython3 |
| 54 | +# Initialize the example design |
| 55 | +design = m.create_design("example-design") |
| 56 | +``` |
| 57 | + |
| 58 | +### Example section: Include images |
| 59 | + |
| 60 | +This section demonstrates how to include static images in the documentation. |
| 61 | +You should place these images in the ``doc/source/_static/`` directory. |
| 62 | + |
| 63 | +You can then reference images in the documentation using the following syntax: |
| 64 | + |
| 65 | +{align=center} |
| 66 | + |
| 67 | + |
| 68 | +### Example section: Create a sketch and plot it |
| 69 | + |
| 70 | +This section demonstrates how to create a sketch and plot it. |
| 71 | + |
| 72 | +```{code-cell} ipython3 |
| 73 | +sketch = Sketch() |
| 74 | +sketch.box(Point2D([0, 0]), 10, 10) |
| 75 | +sketch.plot() |
| 76 | +``` |
| 77 | + |
| 78 | +### Example section: Extrude the sketch and create a body |
| 79 | +This section demonstrates how to extrude the sketch and create a body. |
| 80 | + |
| 81 | +```{code-cell} ipython3 |
| 82 | +design.extrude_sketch(f"BoxBody", sketch, distance=10) |
| 83 | +design.plot() |
| 84 | +``` |
| 85 | + |
| 86 | +## Close the modeler |
| 87 | + |
| 88 | +```{code-cell} ipython3 |
| 89 | +# Close the modeler |
| 90 | +m.close() |
| 91 | +``` |
0 commit comments