Skip to content

Commit 9d5d90f

Browse files
RobPasMuepre-commit-ci[bot]pyansys-ci-botRevathyvenugopal162jorgepiloto
authored
docs: adding cheat sheet on documentation (#1433)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Revathy Venugopal <104772255+Revathyvenugopal162@users.noreply.github.com> Co-authored-by: Revathyvenugopal162 <revathy.venugopal@ansys.com> Co-authored-by: Jorge Martínez <28702884+jorgepiloto@users.noreply.github.com>
1 parent 93ab6ca commit 9d5d90f

File tree

6 files changed

+187
-0
lines changed

6 files changed

+187
-0
lines changed

.github/workflows/ci_cd.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ jobs:
290290
with:
291291
python-version: ${{ env.MAIN_PYTHON_VERSION }}
292292
add-pdf-html-docs-as-assets: true
293+
needs-quarto: true
293294

294295
- name: Stop the Geometry service
295296
if: always()

doc/changelog.d/1433.documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
adding cheat sheet on documentation

doc/source/cheatsheet/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
MyDesign.*

doc/source/cheatsheet/cheat_sheet.qmd

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
title: PyAnsys Geometry cheat sheet
3+
format: cheat_sheet-pdf
4+
params:
5+
version: main
6+
footer: PyAnsys Geometry
7+
footerlinks:
8+
- urls: 'https://geometry.docs.pyansys.com/version/stable/'
9+
text: Documentation
10+
- urls: 'https://geometry.docs.pyansys.com/version/stable/getting_started/index.html'
11+
text: Getting started
12+
- urls: 'https://geometry.docs.pyansys.com/version/stable/examples.html'
13+
text: Examples
14+
- urls: 'https://geometry.docs.pyansys.com/version/stable/api/index.html'
15+
text: API reference
16+
- urls: 'https://geometry.docs.pyansys.com/version/stable/getting_started/faq.html'
17+
text: FAQ
18+
- urls: 'https://github.com/ansys/pyansys-geometry/discussions'
19+
text: Discussions
20+
- urls: 'https://github.com/ansys/pyansys-geometry/issues'
21+
text: 'Issues'
22+
# execute:
23+
# output: false
24+
25+
latex-clean: true
26+
jupyter:
27+
jupytext:
28+
text_representation:
29+
extension: .qmd
30+
format_name: quarto
31+
format_version: '1.0'
32+
jupytext_version: 1.16.1
33+
kernelspec:
34+
display_name: Python 3 (ipykernel)
35+
language: python
36+
name: python3
37+
---
38+
39+
# Verify your installation
40+
41+
## Check your PyAnsys Geometry version
42+
```{python}
43+
from ansys.geometry.core import __version__
44+
print(f"PyAnsys Geometry version: {__version__}")
45+
```
46+
47+
# Sketching
48+
49+
There are two ways of creating 2D sketches in PyAnsys Geometry.
50+
51+
```{python}
52+
from ansys.geometry.core.sketch import Sketch
53+
from ansys.geometry.core.math import Point2D
54+
```
55+
56+
## Functional-style sketching
57+
58+
```{python}
59+
#| output: false
60+
sketch = Sketch()
61+
62+
(
63+
sketch
64+
.segment_to_point(Point2D([3, 3]), "Segment2")
65+
.segment_to_point(Point2D([3, 2]), "Segment3")
66+
.segment_to_point(Point2D([0, 0]), "Segment4")
67+
)
68+
```
69+
70+
You can visualize the sketch by calling the `plot` method.
71+
72+
```{python}
73+
#| output: false
74+
sketch.plot()
75+
```
76+
77+
## Object-oriented sketching
78+
79+
```{python}
80+
#| output: false
81+
sketch = Sketch()
82+
83+
sketch.triangle(
84+
Point2D([-10, 10]),
85+
Point2D([5, 6]),
86+
Point2D([-10, -10]),
87+
)
88+
```
89+
90+
# Modeling
91+
92+
## Launch a modeling session
93+
94+
```{python}
95+
from ansys.geometry.core import launch_modeler
96+
modeler = launch_modeler()
97+
print(modeler)
98+
```
99+
100+
By default, it will detect which modeling service
101+
is available on your system and launch it. If you
102+
have multiple modeling services installed, you can
103+
specify which one to use by passing the `mode` argument.
104+
105+
```{python}
106+
#| eval: false
107+
modeler = launch_modeler(mode='spaceclaim')
108+
modeler = launch_modeler(mode='discovery')
109+
modeler = launch_modeler(mode='geometry_service')
110+
```
111+
112+
## Connect to an existing modeler
113+
114+
```{python}
115+
#| output: false
116+
from ansys.geometry.core import Modeler
117+
modeler = Modeler()
118+
print(modeler)
119+
```
120+
121+
## Create a design
122+
123+
```{python}
124+
design = modeler.create_design("MyDesign")
125+
print(design)
126+
```
127+
128+
## Create a body by extruding a sketch
129+
130+
```{python}
131+
body = design.extrude_sketch("MyBody", sketch, 2)
132+
print(body)
133+
```
134+
135+
## Plot the design
136+
137+
```{python}
138+
#| output: false
139+
design.plot()
140+
```
141+
142+
## Export the design to a file
143+
144+
```{python}
145+
scdocx_path = design.export_to_scdocx()
146+
pmdb_path = design.export_to_pmdb()
147+
para_txt_path = design.export_to_parasolid_text()
148+
para_bin_path = design.export_to_parasolid_bin()
149+
fmd_path = design.export_to_fmd()
150+
step_path = design.export_to_step()
151+
iges_path = design.export_to_iges()
152+
```
153+
154+
# Extra: Product scripting
155+
156+
Ansys SpaceClaim and Ansys Discovery support product scripting, and
157+
so does the Ansys Geometry service. If you have a product script you
158+
want to run, you can use the `run_discovery_script_file` method available
159+
on the `Modeler` object. The ``script_args`` parameter is optional and they
160+
will be made available to the script inside a dictionary called ``argsDict``.
161+
162+
```{python}
163+
#| eval: false
164+
result = modeler.run_discovery_script_file(
165+
file_path="path/to/script.py",
166+
script_args={"arg1": "value1", "arg2": "value2"},
167+
)
168+
```

doc/source/conf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ def intersphinx_pyansys_geometry(switcher_version: str):
163163
"ansys_sphinx_theme_autoapi": {
164164
"project": project,
165165
},
166+
"cheatsheet": {
167+
"file": "cheatsheet/cheat_sheet.qmd",
168+
"pages": ["index", "getting_started/index", "user_guide/index"],
169+
"title": "PyAnsys Geometry cheat sheet",
170+
"version": __version__,
171+
},
166172
"static_search": {
167173
"threshold": 0.5,
168174
"min_chars_for_search": 2,
@@ -440,6 +446,7 @@ def setup(app: sphinx.application.Sphinx):
440446
Sphinx instance containing all the configuration for the documentation build.
441447
"""
442448
logger.info("Configuring Sphinx hooks...")
449+
443450
if BUILD_EXAMPLES:
444451
# Run at the end of the build process
445452
logger.info("Connecting build-finished hook for converting notebooks to scripts...")

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ tests-minimal = [
7676
]
7777
doc = [
7878
"ansys-sphinx-theme[autoapi]==1.1.2",
79+
"ansys-tools-path==0.6.0",
7980
"ansys-tools-visualization-interface==0.4.5",
8081
"beartype==0.19.0",
8182
"docker==7.1.0",
83+
"grpcio==1.66.2",
84+
"grpcio-health-checking==1.66.2",
8285
"ipyvtklink==0.2.3",
8386
"jupyter_sphinx==0.5.3",
8487
"jupytext==1.16.4",
@@ -87,10 +90,15 @@ doc = [
8790
"nbsphinx==0.9.5",
8891
"notebook==7.2.2",
8992
"numpydoc==1.8.0",
93+
"numpy==2.1.2",
9094
"panel==1.5.2",
95+
"Pint==0.24.3",
9196
"protobuf==5.27.2",
9297
"pyvista[jupyter]==0.44.1",
9398
"requests==2.32.3",
99+
"scipy==1.14.1",
100+
"semver==3.0.2",
101+
"six==1.16.0",
94102
"sphinx==8.0.2",
95103
"sphinx-autodoc-typehints==2.4.4",
96104
"sphinx-copybutton==0.5.2",

0 commit comments

Comments
 (0)