top of page

Merge meshes

  • Peter Mortier
  • Jan 19
  • 1 min read

Updated: 6 days ago

In this example, you will learn how to merge multiple meshes into a single mesh. This operation can be useful when creating 3D models.


To illustrate the merging process, we will first create two tubes made up of quadrilateral elements. The first tube is formed by extruding a circle consisting of 20 lines. The second tube is created by connecting a circle to another circle that is scaled and translated, resulting in a cone-like shape.


Merging multiple meshes into a single mesh is straightforward; you simply add the meshes using the + symbol. You can examine the resulting mesh using a print statement. As anticipated, this merged mesh comprises 40 quadrilateral elements (20 from each tube). Although the two original tubes each had 40 nodes, the merged mesh contains only 60 nodes due to the presence of 20 overlapping nodes, which appear only once in the final mesh.


from hellotriangle import shapes

# generate circle
cir = shapes.circle(n=20)

# extrude line to quad mesh
tube1 = cir.extrude(1, dir = [0.0, 0.0, 1.0], length = 2.0)

# create another mesh by connecting a circle to a scaled circle
cir2 = shapes.circle(n=20)
cir2 = cir2.scale([3.0, 2.0, 1.0]).translate([0.0, 0.0, -2.0])
tube2 = cir.connect(cir2,div=1)

# merge the two meshes into a single quad mesh
tube = tube1 + tube2
print(tube)

# draw
draw(cubeRotated, color = "#006992", show_edges = True)

Merge meshes
Figure: Merged mesh obtained by simply adding (+) two separate meshes.

Subscribe to our newsletter

Join our email list and get updates about HelloTriangle. Unsubscribe anytime.

Thanks for submitting!

© 2024 by HelloTriangle

  • LinkedIn
bottom of page