top of page

Extrude mesh

  • Peter Mortier
  • Jan 18
  • 1 min read

Updated: 6 days ago

In this example, you will learn how to generate 3D models by extruding a mesh.


We will demonstrate how to create a cuboid made up of hexahedral elements. We begin by forming a simple line (a 1D mesh) between two points, divided into nx segments. Next, we extrude this mesh in the Y-direction with a specified length ly and ny divisions, producing a 2D mesh of quadrilateral elements. Finally, we extrude this quadrilateral mesh in the Z-direction, again with a specified length (lz) and nz divisions. The resulting hexahedral mesh is depicted in the figure below. Please note that any vector or direction can be utilized by the extrude function.


from hellotriangle import shapes

# geometrical parameters
lx = 10.
ly = 3.
lz = 5.

# mesh parameters
nx = 5
ny = 2
nz = 10

# generate line
line = shapes.line([0.0, 0.0, 0.0], [lx, 0.0, 0.0], nx)

# extrude line to quadrilateral mesh
quad = line.extrude(ny, dir = [0.0, 1.0, 0.0], length = ly)

# extrude quad to hex mesh
hex = quad.extrude(nz, dir = [0.0, 0.0, 1.0], length = lz)

# draw hex mesh with edges
draw(hex, color = "#2BB786", show_edges = True)

Extrude mesh
Figure: Resulting mesh after applying two extrusions. The first mesh extrusion transforms a simple line into a quadrilateral mesh. The second extrusion generates the hexahedral mesh.

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