From 3e70c7d53251d0735ed4a8329f70108ee9ba9bae Mon Sep 17 00:00:00 2001 From: Roberto Pastor Muela <37798125+RobPasMue@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:52:08 +0200 Subject: [PATCH] docs: revisit examples to make sure they are properly styled --- .../05_plotter_picker.mystnb | 5 +--- .../examples/03_modeling/design_tree.mystnb | 6 ++-- .../scale_map_mirror_bodies.mystnb | 4 +-- .../03_modeling/service_colors.mystnb | 27 ++++++++--------- .../03_modeling/surface_bodies.mystnb | 30 ++++++++++++------- 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/doc/source/examples/01_getting_started/05_plotter_picker.mystnb b/doc/source/examples/01_getting_started/05_plotter_picker.mystnb index d647dcff66..9f14267956 100644 --- a/doc/source/examples/01_getting_started/05_plotter_picker.mystnb +++ b/doc/source/examples/01_getting_started/05_plotter_picker.mystnb @@ -31,9 +31,6 @@ Perform the required imports. from pint import Quantity import pyvista as pv -from ansys.geometry.core import Modeler -from ansys.geometry.core.connection.defaults import GEOMETRY_SERVICE_DOCKER_IMAGE -from ansys.geometry.core.connection.docker_instance import LocalDockerInstance from ansys.geometry.core.math import Point2D from ansys.geometry.core.misc import UNITS from ansys.geometry.core.plotting import GeometryPlotter @@ -220,7 +217,7 @@ You can render the objects in different colors automatically using PyVista's def color cycler. In order to do this, activate the ``multi_colors=True`` option when calling the ``plot()`` method. -In the following cell we will create a new design and plot a prism and a cylinder in different colors. +In the following cell you can create a new design and plot a prism and a cylinder in different colors. ```{code-cell} ipython design = modeler.create_design("MultiColors") diff --git a/doc/source/examples/03_modeling/design_tree.mystnb b/doc/source/examples/03_modeling/design_tree.mystnb index db9dfb71a9..eeb7061ca4 100644 --- a/doc/source/examples/03_modeling/design_tree.mystnb +++ b/doc/source/examples/03_modeling/design_tree.mystnb @@ -18,7 +18,7 @@ structure of the model in the terminal. ## Perform required imports -For the following example, we need to import these modules: +For the following example, you need to import these modules: ```{code-cell} ipython3 from pint import Quantity @@ -60,7 +60,7 @@ distance = 30 * UNITS.m # # # Now, only "comp_3", "nested_2_comp_1" and "nested_1_nested_1_comp_1" -# will have a body associated. +# has a body associated. # # Create the components @@ -106,7 +106,7 @@ design.tree_print() ### Controlling the depth of the tree The ``tree_print()`` method accepts an optional argument ``depth`` to control the depth of the -tree to be printed. The default value is ``None``, which means the entire tree will be printed. +tree to be printed. The default value is ``None``, which means the entire tree is printed. ```{code-cell} ipython3 design.tree_print(depth=1) diff --git a/doc/source/examples/03_modeling/scale_map_mirror_bodies.mystnb b/doc/source/examples/03_modeling/scale_map_mirror_bodies.mystnb index c96ac57d53..5a8071c2ad 100644 --- a/doc/source/examples/03_modeling/scale_map_mirror_bodies.mystnb +++ b/doc/source/examples/03_modeling/scale_map_mirror_bodies.mystnb @@ -51,7 +51,7 @@ dynamic resizing of bodies. To use the ``scale()`` function, you call it on an instance of a geometry body, passing a single argument: the scale value. This value is a real number (``Real``) that determines -the factor by which the body's size will be changed. +the factor by which the body's size is changed. ```python body.scale(value) @@ -302,7 +302,7 @@ design.plot() #### Mirror the triangular body -We will first make a copy of the triangular body, then using ``mirror()``, we will mirror the +First, make a copy of the triangular body. Then, using ``mirror()``, you can mirror the copied body over the ZY plane. ```{code-cell} ipython3 diff --git a/doc/source/examples/03_modeling/service_colors.mystnb b/doc/source/examples/03_modeling/service_colors.mystnb index bd8f771221..0bf05c17ac 100644 --- a/doc/source/examples/03_modeling/service_colors.mystnb +++ b/doc/source/examples/03_modeling/service_colors.mystnb @@ -50,9 +50,9 @@ design = modeler.create_design("ServiceColors") ## Extrude the box sketch to create the matrix style design -Given our initial sketch, we will extrude it to create a matrix style design. -We will create a 2x3 matrix of bodies. Each body will be separated by 30 units -in the X direction and 30 units in the Y direction. We will have a total of 6 bodies. +Given the initial sketch, you can extrude it to create a matrix style design. +In this example, you can create a 2x3 matrix of bodies. Each body is separated by 30 units +in the X direction and 30 units in the Y direction. You have a total of 6 bodies. ```{code-cell} ipython3 translate = [[0, 30, 60], [0, 30, 60]] @@ -70,10 +70,9 @@ design.plot() ## Assign colors to the bodies -Given our previous design, we will assign a color to each body. We will assign -a different color to each one of them. We could have done this assignment while -creating the bodies, but we will do it now for the sake of encapsulating the -color assignment logic. +Given the previous design, you can assign a color to each body. You could have done +this assignment while creating the bodies, but for the sake of encapsulating the +color assignment logic, it is done in its own code cell. ```{code-cell} ipython3 @@ -87,8 +86,8 @@ for c_idx, comp in enumerate(design.components): ## Plotting the design with colors -By default, the plot method will **not** use the colors assigned to the bodies. -To plot the design with the assigned colors, we need to specifically request it. +By default, the plot method does **not** use the colors assigned to the bodies. +To plot the design with the assigned colors, you need to specifically request it. Users have two options for plotting with the assigned colors: @@ -99,21 +98,21 @@ It is important to note that the usage of colors when plotting might slow down t plotting process, as it requires additional information to be sent from the server to the client and processed in the client side. -If we just request the plot without setting the global parameter, the plot will +If you just request the plot without setting the global parameter, the plot will be displayed without the colors, as shown below. ```{code-cell} ipython3 design.plot() ``` -As stated previously, if we pass the parameter ``use_service_colors=True`` to the plot -method, the plot will be displayed with the assigned colors. +As stated previously, if you pass the parameter ``use_service_colors=True`` to the plot +method, the plot is displayed with the assigned colors. ```{code-cell} ipython3 design.plot(use_service_colors=True) ``` -However, if we set the global parameter to ``True``, the plot will be displayed +However, if you set the global parameter to ``True``, the plot is displayed with the assigned colors without the need to pass the parameter to the plot method. ```{code-cell} ipython3 @@ -138,7 +137,7 @@ If the user wants to plot specific bodies with the assigned colors, the user can follow the same approach as before. The user can pass the parameter ``use_service_colors=True`` to the plot method or set the global parameter ``USE_SERVICE_COLORS`` to ``True``. -In the following examples, we will just demonstrate how to do this using the +In the following examples, you are shown how to do this using the ``use_service_colors=True`` parameter. Let's plot the first body of the first component with the assigned colors. diff --git a/doc/source/examples/03_modeling/surface_bodies.mystnb b/doc/source/examples/03_modeling/surface_bodies.mystnb index 5ea0ffbd95..6febd3cd8d 100644 --- a/doc/source/examples/03_modeling/surface_bodies.mystnb +++ b/doc/source/examples/03_modeling/surface_bodies.mystnb @@ -12,9 +12,12 @@ kernelspec: --- # Modeling: Surface bodies and trimmed surfaces -This example will show how to trim different surfaces, and how to use those surfaces to create surface bodies. + +This example shows how to trim different surfaces, and how to use those surfaces +to create surface bodies. ## Create a surface + Create a sphere surface. This can be done without launching the modeler. ```{code-cell} ipython3 @@ -31,7 +34,10 @@ surface.parameterization() ``` ## Trim the surface -For a sphere, its parametization is (`u: [0, 2*pi]`, `v:[-pi/2, pi/2]`), where u corresponds to longitude and v corresponds to latitude. We can **trim** a surface by providing new parameters. + +For a sphere, its parametization is (`u: [0, 2*pi]`, `v:[-pi/2, pi/2]`), +where u corresponds to longitude and v corresponds to latitude. You +can **trim** a surface by providing new parameters. ```{code-cell} ipython3 from ansys.geometry.core.shapes.box_uv import BoxUV @@ -41,7 +47,7 @@ import math trimmed_surface = surface.trim(BoxUV(range_u=Interval(0, math.pi), range_v=Interval(0, math.pi/2))) ``` -From a TrimmedSurface, you can always refer back to the underlying Surface if needed. +From a ``TrimmedSurface``, you can always refer back to the underlying ``Surface`` if needed. ```{code-cell} ipython3 trimmed_surface.geometry @@ -49,7 +55,8 @@ trimmed_surface.geometry ## Create a surface body -Now create a surface body by launching the modeler session and providing the trimmed surface. Then plot the body to see how we created a quarter of a sphere as a surface body. +Now create a surface body by launching the modeler session and providing the trimmed surface. +Then plot the body to see how you created a quarter of a sphere as a surface body. ```{code-cell} ipython3 from ansys.geometry.core import launch_modeler @@ -64,20 +71,23 @@ body = design.create_body_from_surface("trimmed_sphere", trimmed_surface) design.plot() ``` -If the sphere was left untrimmed, it would create a solid body since the surface is fully closed. In this case, since the surface was open, it created a surface body. +If the sphere was left untrimmed, it would create a solid body since the surface is fully +closed. In this case, since the surface was open, it created a surface body. This same process can be used with other surfaces including: -- cone -- cylinder -- plane -- torus +- ``Cone`` +- ``Cylinder`` +- ``Plane`` +- ``Torus`` Each surface has its own unique parameterization, which must be understood before trying to trim it. +++ ## Close session -When you finish interacting with your modeling service, you should close the active server session. This frees resources wherever the service is running. + +When you finish interacting with your modeling service, you should close the active server +session. This frees resources wherever the service is running. Close the server session.