Download this example
Download this example as a Jupyter Notebook or as a Python script.
Modeling: Tessellation of two bodies#
This example shows how to create two stacked bodies and return the tessellation as two merged bodies.
Perform required imports#
Perform the required imports.
[1]:
from pint import Quantity
from ansys.geometry.core import launch_modeler
from ansys.geometry.core.math import Point2D, Point3D, Plane
from ansys.geometry.core.misc import UNITS
from ansys.geometry.core.sketch import Sketch
Create design#
Create the basic sketches to be tessellated and extrude the sketch in the required plane. For more information on creating a component and extruding a sketch in the design, see the Rectangular plate with multiple bodies example.
Here is a typical situation in which two bodies, with different sketch planes, merge each body into a single dataset. This effectively combines all the faces of each individual body into a single dataset without separating faces.
[2]:
modeler = launch_modeler()
sketch_1 = Sketch()
box = sketch_1.box(
Point2D([10, 10], unit=UNITS.m), width=Quantity(10, UNITS.m), height=Quantity(5, UNITS.m)
)
circle = sketch_1.circle(
Point2D([0, 0], unit=UNITS.m), radius=Quantity(25, UNITS.m)
)
design = modeler.create_design("TessellationDesign")
comp = design.add_component("TessellationComponent")
body = comp.extrude_sketch("Body", sketch=sketch_1, distance=10 * UNITS.m)
# Create the second body in a plane with a different origin
sketch_2 = Sketch(Plane([0, 0, 10]))
box = sketch_2.box(Point2D(
[10, 10], unit=UNITS.m), width=Quantity(10, UNITS.m), height=Quantity(5, UNITS.m)
)
circle = sketch_2.circle(
Point2D([0, 10], unit=UNITS.m), radius=Quantity(25, UNITS.m)
)
body = comp.extrude_sketch("Body", sketch=sketch_2, distance=10 * UNITS.m)
/home/runner/work/pyansys-geometry/pyansys-geometry/.venv/lib/python3.13/site-packages/ansys/geometry/core/connection/launcher.py:364: UserWarning: Transport mode forced to 'insecure' when running in CI workflows.
warnings.warn(
/home/runner/work/pyansys-geometry/pyansys-geometry/.venv/lib/python3.13/site-packages/ansys/tools/common/cyberchannel.py:183: UserWarning: Starting gRPC client without TLS on localhost:700. This is INSECURE. Consider using a secure connection.
warn(f"Starting gRPC client without TLS on {target}. This is INSECURE. Consider using a secure connection.")
Tessellate component as two merged bodies#
Tessellate the component and merge each body into a single dataset. This effectively combines all the faces of each individual body into a single dataset without separating faces.
[3]:
dataset = comp.tessellate()
dataset
[3]:
| PolyData | Information |
|---|---|
| N Cells | 976 |
| N Points | 996 |
| N Strips | 0 |
| X Bounds | -2.500e+01, 2.500e+01 |
| Y Bounds | -2.499e+01, 3.499e+01 |
| Z Bounds | 0.000e+00, 2.000e+01 |
| N Arrays | 0 |
Single body tessellation is possible. In that case, users can request the body-level tessellation method to tessellate the body and merge all the faces into a single dataset.
[4]:
dataset = comp.bodies[0].tessellate()
dataset
[4]:
| Information | Blocks | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
Plot design#
Plot the design.
[5]:
design.plot()
Close the modeler#
Close the modeler.
[6]:
modeler.close()
Download this example
Download this example as a Jupyter Notebook or as a Python script.