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)

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]:
PolyDataInformation
N Cells3280
N Points3300
N Strips0
X Bounds-2.500e+01, 2.500e+01
Y Bounds-2.500e+01, 3.500e+01
Z Bounds0.000e+00, 2.000e+01
N Arrays0

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]:
InformationBlocks
MultiBlockValues
N Blocks7
X Bounds-25.000, 25.000
Y Bounds-24.999, 24.999
Z Bounds0.000, 10.000
IndexNameType
0Block-00PolyData
1Block-01PolyData
2Block-02PolyData
3Block-03PolyData
4Block-04PolyData
5Block-05PolyData
6Block-06PolyData

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.