{
"cells": [
{
"cell_type": "markdown",
"id": "15b383a0",
"metadata": {},
"source": [
"# Modeling: Tessellation of two bodies\n",
"\n",
"This example shows how to create two stacked bodies and return the tessellation\n",
"as two merged bodies."
]
},
{
"cell_type": "markdown",
"id": "1b5bb79d",
"metadata": {},
"source": [
"## Perform required imports\n",
"\n",
"Perform the required imports."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "33003111",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-16T11:00:18.769769Z",
"iopub.status.busy": "2025-04-16T11:00:18.769568Z",
"iopub.status.idle": "2025-04-16T11:00:20.354117Z",
"shell.execute_reply": "2025-04-16T11:00:20.353569Z"
}
},
"outputs": [],
"source": [
"from pint import Quantity\n",
"\n",
"from ansys.geometry.core import launch_modeler\n",
"from ansys.geometry.core.math import Point2D, Point3D, Plane\n",
"from ansys.geometry.core.misc import UNITS\n",
"from ansys.geometry.core.sketch import Sketch\n"
]
},
{
"cell_type": "markdown",
"id": "9755c323",
"metadata": {},
"source": [
"## Create design\n",
"\n",
"Create the basic sketches to be tessellated and extrude the sketch in the\n",
"required plane. For more information on creating a component and extruding a\n",
"sketch in the design, see the [Rectangular plate with multiple bodies](plate_with_hole.mystnb)\n",
"example.\n",
"\n",
"Here is a typical situation in which two bodies, with different sketch planes,\n",
"merge each body into a single dataset. This effectively combines all the faces\n",
"of each individual body into a single dataset without separating faces."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2b9e6609",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-16T11:00:20.356686Z",
"iopub.status.busy": "2025-04-16T11:00:20.356103Z",
"iopub.status.idle": "2025-04-16T11:00:20.522046Z",
"shell.execute_reply": "2025-04-16T11:00:20.521417Z"
}
},
"outputs": [],
"source": [
"modeler = launch_modeler()\n",
"\n",
"sketch_1 = Sketch()\n",
"box = sketch_1.box(\n",
" Point2D([10, 10], unit=UNITS.m), width=Quantity(10, UNITS.m), height=Quantity(5, UNITS.m)\n",
")\n",
"circle = sketch_1.circle(\n",
" Point2D([0, 0], unit=UNITS.m), radius=Quantity(25, UNITS.m)\n",
")\n",
"\n",
"design = modeler.create_design(\"TessellationDesign\")\n",
"comp = design.add_component(\"TessellationComponent\")\n",
"body = comp.extrude_sketch(\"Body\", sketch=sketch_1, distance=10 * UNITS.m)\n",
"\n",
"# Create the second body in a plane with a different origin\n",
"sketch_2 = Sketch(Plane([0, 0, 10]))\n",
"box = sketch_2.box(Point2D(\n",
" [10, 10], unit=UNITS.m), width=Quantity(10, UNITS.m), height=Quantity(5, UNITS.m)\n",
")\n",
"circle = sketch_2.circle(\n",
" Point2D([0, 10], unit=UNITS.m), radius=Quantity(25, UNITS.m)\n",
")\n",
"\n",
"body = comp.extrude_sketch(\"Body\", sketch=sketch_2, distance=10 * UNITS.m)"
]
},
{
"cell_type": "markdown",
"id": "8d9d20e6",
"metadata": {},
"source": [
"## Tessellate component as two merged bodies\n",
"\n",
"Tessellate the component and merge each body into a single dataset. This effectively\n",
"combines all the faces of each individual body into a single dataset without\n",
"separating faces."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "26e40e55",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-16T11:00:20.524266Z",
"iopub.status.busy": "2025-04-16T11:00:20.523874Z",
"iopub.status.idle": "2025-04-16T11:00:20.595356Z",
"shell.execute_reply": "2025-04-16T11:00:20.594821Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"
\n",
"PolyData | Information |
\n",
"N Cells | 3280 |
\n",
"N Points | 3300 |
\n",
"N Strips | 0 |
\n",
"X Bounds | -2.500e+01, 2.500e+01 |
\n",
"Y Bounds | -2.500e+01, 3.500e+01 |
\n",
"Z Bounds | 0.000e+00, 2.000e+01 |
\n",
"N Arrays | 0 |
\n",
"
\n",
"\n"
],
"text/plain": [
"PolyData (0x7f3731dbb220)\n",
" N Cells: 3280\n",
" N Points: 3300\n",
" N Strips: 0\n",
" X Bounds: -2.500e+01, 2.500e+01\n",
" Y Bounds: -2.500e+01, 3.500e+01\n",
" Z Bounds: 0.000e+00, 2.000e+01\n",
" N Arrays: 0"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset = comp.tessellate()\n",
"dataset"
]
},
{
"cell_type": "markdown",
"id": "7f8e5f5f",
"metadata": {},
"source": [
"Single body tessellation is possible. In that case, users can request the body-level tessellation\n",
"method to tessellate the body and merge all the faces into a single dataset."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "ca7a9976",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-16T11:00:20.597634Z",
"iopub.status.busy": "2025-04-16T11:00:20.597096Z",
"iopub.status.idle": "2025-04-16T11:00:20.604996Z",
"shell.execute_reply": "2025-04-16T11:00:20.604454Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"Information | Blocks |
---|
\n",
"\n",
"MultiBlock | Values | \n",
"N Blocks | 7 | \n",
"X Bounds | -25.000, 25.000 | \n",
"Y Bounds | -24.999, 24.999 | \n",
"Z Bounds | 0.000, 10.000 | \n",
" \n",
"\n",
" | \n",
"\n",
"Index | Name | Type | \n",
"0 | Block-00 | PolyData | \n",
"1 | Block-01 | PolyData | \n",
"2 | Block-02 | PolyData | \n",
"3 | Block-03 | PolyData | \n",
"4 | Block-04 | PolyData | \n",
"5 | Block-05 | PolyData | \n",
"6 | Block-06 | PolyData | \n",
" \n",
"\n",
" |
"
],
"text/plain": [
"MultiBlock (0x7f3731dbada0)\n",
" N Blocks 7\n",
" X Bounds -25.000, 25.000\n",
" Y Bounds -24.999, 24.999\n",
" Z Bounds 0.000, 10.000"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dataset = comp.bodies[0].tessellate()\n",
"dataset"
]
},
{
"cell_type": "markdown",
"id": "39280363",
"metadata": {},
"source": [
"## Plot design\n",
"\n",
"Plot the design."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "36560c75",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-16T11:00:20.606829Z",
"iopub.status.busy": "2025-04-16T11:00:20.606624Z",
"iopub.status.idle": "2025-04-16T11:00:21.119220Z",
"shell.execute_reply": "2025-04-16T11:00:21.118527Z"
}
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2ad28d94ad2340e78ee876d247d6a442",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"EmbeddableWidget(value='"
}
},
"2bd738b7b1144f48bf34c0396db23ca7": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "1.5.0",
"model_name": "DescriptionStyleModel",
"state": {
"_model_module": "@jupyter-widgets/controls",
"_model_module_version": "1.5.0",
"_model_name": "DescriptionStyleModel",
"_view_count": null,
"_view_module": "@jupyter-widgets/base",
"_view_module_version": "1.2.0",
"_view_name": "StyleView",
"description_width": ""
}
}
},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}