Skip to main content

Sweep

sweep() moves a profile along a path to create a solid. It's used for pipes, rails, and any shape that follows a curve.

import { sketch, sweep } from 'fluidcad/core';
import { circle, vLine, tArc } from 'fluidcad/core';

const profile = sketch("top", () => {
circle(40)
circle(20)
})

const spine = sketch("front", () => {
vLine(100)
tArc(50, 180)
tArc(80, -270)
})

sweep(spine, profile)

Sweep along a curved path

The first argument is the path (spine), the second is the profile to sweep. The profile and path should be on different planes.

Thin sweep

.thin() offsets the profile edges to create a thin-walled swept shell — useful for pipes and ducts:

import { sketch, sweep } from 'fluidcad/core';
import { circle, vLine, tArc } from 'fluidcad/core';

const profile = sketch("top", () => {
circle(40)
})

const spine = sketch("front", () => {
vLine(100)
tArc(50, 180)
tArc(80, -270)
})

sweep(spine, profile).thin(5)

Thin sweep

sweep(spine, profile).thin(5) // 5 units outward
sweep(spine, profile).thin(-5) // 5 units inward
sweep(spine, profile).thin(5, -3) // dual offset

Open profiles

Thin sweep also works with open profiles. The ends are capped — select them with capFaces() / capEdges():

import { sketch, sweep } from 'fluidcad/core';
import { line, vLine, tArc } from 'fluidcad/core';

const profile = sketch("top", () => {
line([-30, 0], [30, 0])
})

const spine = sketch("front", () => {
vLine(100)
tArc(50, 180)
})

sweep(spine, profile).thin(5).new()

Thin sweep — open profile

Accessing geometry

const s = sweep(spine, profile)

s.endFaces() // face at the end of the path
s.startFaces() // face at the start of the path
s.sideFaces() // the swept surface(s)
s.endEdges() // edges at the end
s.startEdges() // edges at the start
s.sideEdges() // edges along the sides
s.internalFaces() // internal faces (if profile has holes)
s.internalEdges() // internal edges
s.capFaces() // cap face(s) of a thin sweep (open profile)
s.capEdges() // cap edges of a thin sweep (open profile)

Fusion scope

sweep(spine, profile).new() // create a separate solid
sweep(spine, profile).add() // fuse with touching solids (default)
sweep(spine, profile).remove() // subtract from all intersecting solids
sweep(spine, profile).remove().scope(box) // subtract only from the box