mesh.Mesh.sweep#
- Mesh.sweep(path, eltype=None, csys=None, fuse=True, chained=True, fix=True)#
Sweep a Mesh along a path, creating an extrusion.
Parameters#
- path: Curve object | Mesh object
The path over which to sweep the Mesh. A Mesh can be provided, if this Mesh can be converted to a Curve using the
to_curve()method.- eltype: str or
ElementType, optional The element type of the constructed hypermesh. Normally, this is set automatically from the base element type and the connection degree. If a different element type is specified, a final conversion to the requested element type is attempted (using
convert()).- csys:
CoordSys The coordinate system that will be positioned along the frenet axes. If not provided, the global axes are used.
- fusebool, default=True
If True, the resulting Mesh will be fused when sweeping along a closed path or closed branch. Nodes of different branches, if present, are not fused.
- chainedbool, default=True
If True and path is provided as a Mesh, it is first processed with
chained()to reorder line elements into connected chains before being converted to a Curve.If multiple chains are found, the cross-section is swept along each chain individually, and the results are concatenated into a single Mesh (without fusing branches).
If False, the path Mesh is converted to a Curve as-is.
- fix: bool
If True (default), elements with negative volumes are automatically corrected after connecting the meshes. This is done by calling
fix_volumes(), which reverses the orientation of elements that have negative volume to ensure positive volume.
Returns#
- Mesh
A Mesh obtained by sweeping the given cross-section Mesh (self) along the path.
If the path or branch is closed, fuse determines whether nodes are fused at the closure.
If multiple chains are present, the sweeps are concatenated into a single Mesh without fusing branches.
Notes#
This operation is similar to the
extrude()method, but the path can be any 3D curve.Important
If you do not provide a coordinate system, the sweep will align the X-axis with the path. In this case, the input Mesh should usually be drawn in the YZ plane (perpendicular to X), so that sweeping produces the intended shape.
See Also#
Examples#
>>> path1 = Mesh(eltype='line2') >>> path1 = path1.subdivide(4).scale(3) >>> quad = Mesh(eltype='quad4').rotate_y(90.0) >>> hex = quad.sweep(path1) >>> print(hex) Mesh: n_nodes: 20, n_elems: 4, plexitude: 8, level: 3, eltype: hex8 BBox: [ 0. 0. -1.], [3. 1. 0.] Size: [3. 1. 1.] Area: 14.0 Volume: 3.0 >>> path2 = path1.rotate_z(90.).translate([-1.0,0.0,0.0]) >>> path = path1+path2 >>> hex = quad.sweep(path) >>> print(len(hex.split_by_connection())) 2