Sweep profile along a path
- Peter Mortier
- Jan 19
- 1 min read
Updated: 6 days ago
Learn how to sweep a profile along a path with only a few lines of Python code.
Creating a 3D model through sweeping is a powerful method that allows you to create quite advanced models. In this example, we will create a quadrilateral profile, consisting of 1D line elements. We also generate a 270-degree arc. Finally, we sweep the profile along the arc using the sweep function.
A few important notes:
The quadrilateral profile has its coordinates in the XY-plane, so the normal of this profile is in the Z-direction. We need to provide this normal as an argument when using the sweep function.
If we sweep 1D line elements, then the resulting mesh consists of 2D quadrilateral elements. If we sweep 2D quadrilateral elements, then the resulting mesh will consist of 3D hexahedral elements.
from hellotriangle import shapes
# generate quadrilateral profile
profile = shapes.quad(eltype = 'line2').scale([0.5, 0.3, 1.0])
# generate arc
arc = shapes.arc(angle = 270., n = 20)
# sweep quad profile along path
quad = profile.sweep(arc, normal = [0.0, 0.0, 1.0])
# draw
draw(quad, color = "grey", show_edges = True)
