-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement cut operation in extrude sketch (#1510)
Co-authored-by: pyansys-ci-bot <92810346+pyansys-ci-bot@users.noreply.github.com> Co-authored-by: Kathy Pippert <84872299+PipKat@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
8b919dd
commit d25808d
Showing
9 changed files
with
226 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
implement cut operation in extrude sketch |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
doc/source/examples/03_modeling/cut_operation_on_extrude.mystnb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
--- | ||
jupytext: | ||
text_representation: | ||
extension: .mystnb | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.14.1 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
# Modeling: Extruded plate with cut operations | ||
|
||
As seen in the [Rectangular plate with multiple bodies](./plate_with_hole.mystnb) example, | ||
you can create a complex sketch with holes and extrude it to create a body. However, you can also | ||
perform cut operations on the extruded body to achieve similar results. | ||
|
||
+++ | ||
|
||
## Perform required imports | ||
|
||
Perform the required imports. | ||
|
||
```{code-cell} ipython3 | ||
from pint import Quantity | ||
|
||
from ansys.geometry.core import launch_modeler | ||
from ansys.geometry.core.math import Plane, Point3D, Point2D | ||
from ansys.geometry.core.misc import UNITS | ||
from ansys.geometry.core.sketch import Sketch | ||
``` | ||
|
||
## Define sketch profile without holes | ||
|
||
Create a sketch profile for the proposed design. The sketch is the same as the | ||
[Rectangular plate with multiple bodies](./plate_with_hole.mystnb) example, but without the holes. | ||
|
||
These holes are created by performing cut operations on the extruded body in the next steps. | ||
|
||
|
||
```{code-cell} ipython3 | ||
sketch = Sketch() | ||
(sketch.segment(Point2D([-4, 5], unit=UNITS.m), Point2D([4, 5], unit=UNITS.m)) | ||
.segment_to_point(Point2D([4, -5], unit=UNITS.m)) | ||
.segment_to_point(Point2D([-4, -5], unit=UNITS.m)) | ||
.segment_to_point(Point2D([-4, 5], unit=UNITS.m)) | ||
.box(Point2D([0,0], unit=UNITS.m), Quantity(3, UNITS.m), Quantity(3, UNITS.m)) | ||
) | ||
|
||
modeler = launch_modeler() | ||
design = modeler.create_design("ExtrudedPlateNoHoles") | ||
body = design.extrude_sketch(f"PlateLayer", sketch, Quantity(2, UNITS.m)) | ||
|
||
design.plot() | ||
``` | ||
|
||
## Define sketch profile for holes | ||
|
||
Create a sketch profile for the holes in the proposed design. The holes are created by | ||
sketching circles at the four corners of the plate. First create a reference sketch | ||
for all the circles. This sketch is translated to the four corners of the plate. | ||
|
||
```{code-cell} ipython3 | ||
sketch_hole = Sketch() | ||
sketch_hole.circle(Point2D([0, 0], unit=UNITS.m), Quantity(0.5, UNITS.m)) | ||
|
||
hole_centers = [ | ||
Plane(Point3D([3, 4, 0], unit=UNITS.m)), | ||
Plane(Point3D([-3, 4, 0], unit=UNITS.m)), | ||
Plane(Point3D([-3, -4, 0], unit=UNITS.m)), | ||
Plane(Point3D([3, -4, 0], unit=UNITS.m)), | ||
] | ||
``` | ||
|
||
## Perform cut operations on the extruded body | ||
|
||
Perform cut operations on the extruded body to create holes at the four corners of the plate. | ||
|
||
```{code-cell} ipython3 | ||
for center in hole_centers: | ||
sketch_hole.plane = center | ||
design.extrude_sketch( | ||
name= f"H_{center.origin.x}_{center.origin.y}", | ||
sketch=sketch_hole, | ||
distance=Quantity(2, UNITS.m), | ||
cut=True, | ||
) | ||
|
||
design.plot() | ||
``` | ||
|
||
## Close the modeler | ||
|
||
Close the modeler to free up resources and release the connection. | ||
|
||
```{code-cell} ipython3 | ||
modeler.close() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters