offset()
[3D] Offsets curves along faces, written outside a sketch: a curve
beside edges at distance, measured straight through space, lying on
the faces given in { on } — a line set back from an edge of a body, the
inner boundary of a band along a rim, a curve beside a projected curve.
The sign picks the side. Walking along the edges standing on the outside of the faces, a positive distance goes to the left, a negative one to the right. Edges along the rim of the faces — one face beside each — are walked the way that face's boundary runs, so a positive distance goes onto the faces.
The result holds one curve per chain of the edges, each running the same
way as its source, in source order: edges(), start() and end()
read it. A sketch or a curve given as the edges is hidden and stays
readable; the faces are read, not used up.
Returns: OffsetCurve | Offset | OffsetSurface
See the guide for detailed usage examples.
Signatures
offset(distance: NumberParam, edges: SceneObject | SceneObject[], options: { on: ISceneObject | ISceneObject[]; }): OffsetCurve
[3D] Offsets curves along faces, written outside a sketch: a curve
beside edges at distance, measured straight through space, lying on
the faces given in { on } — a line set back from an edge of a body, the
inner boundary of a band along a rim, a curve beside a projected curve.
The sign picks the side. Walking along the edges standing on the outside of the faces, a positive distance goes to the left, a negative one to the right. Edges along the rim of the faces — one face beside each — are walked the way that face's boundary runs, so a positive distance goes onto the faces.
The result holds one curve per chain of the edges, each running the same
way as its source, in source order: edges(), start() and end()
read it. A sketch or a curve given as the edges is hidden and stays
readable; the faces are read, not used up.
| Parameter | Type | Description |
|---|---|---|
distance | NumberParam | The distance, not zero: positive for the left side, negative for the right. |
edges | SceneObject | SceneObject[] | Curves: a selection of edges, a curve object, a sketch, or a list of those. They must lie on the faces. |
options | { on: ISceneObject | ISceneObject[]; } | { on }: the faces the curve lies on — a face selection, a surface, a solid, or a list of those. |
offset(distance?: NumberParam, ...targets: (Geometry | EdgeFilter)[]): Offset
[2D] Offsets sketch geometry, written inside a sketch(…) callback: each
chain of the targets is offset on the sketch plane by distance, a
closed loop outward for a positive distance and inward for a negative
one, an open chain to its left or right. With no targets, offsets the
whole sketch, or the select(…) written just before it in the sketch.
The result is sketch geometry: mark the sources .guide() to keep them
out of the profile, chain .close() to cap an open offset.
| Parameter | Type | Description |
|---|---|---|
distance | NumberParam | The offset distance (defaults to 1): positive grows a closed loop, negative shrinks it. (optional) |
...targets | (Geometry | EdgeFilter)[] | Optional geometries to offset instead of the whole sketch — statements, projections (project(face)), edge accessors (l.edge(0)) — or edge filters (edge().arc()). (optional) |
offset(distance: NumberParam, ...faces: (SceneObject | SceneObject[])[]): OffsetSurface
[3D] Offsets faces, written outside a sketch: a surface at distance
from the faces along their normals — out of a solid's material, or to a
surface's own side, for a positive distance; the other way for a
negative one. A distance of 0 copies the faces where they are.
Faces of one body that share edges make one surface, their offsets
extended or trimmed to meet again where the faces meet at a sharp edge;
faces of different bodies, or that do not touch, make one surface each.
faces() and boundaryEdges() read the result. With no faces given,
the select(…) written just before it is used. The faces are read, not
used up; a selection's highlight leaves the display.
Before, this form traced the outline of coplanar faces as edges to
extrude. That outline is now drawn in a sketch on the face,
sketch(face, () => { offset(d, project(face).guide()) }), the face's
holes, if any, projected and offset apart by -d.
| Parameter | Type | Description |
|---|---|---|
distance | NumberParam | The distance: positive along the faces' normals, negative against them, 0 for a copy. |
...faces | (SceneObject | SceneObject[])[] | Faces of solids or of surfaces (a face selection, b.sideFaces()), whole surfaces, whole solids, or lists of those. (optional) |
Examples
// @screenshot hideGrid
import { sketch, circle, extrude, offset } from 'fluidcad/core';
sketch('xy', () => {
circle([0, 0], 40);
});
const body = extrude(20);
// Outside a sketch, with { on }: a curve 3 below the top rim, on the side
// wall. From a rim, a positive distance goes onto the faces.
const band = offset(3, body.endEdges(), { on: body.sideFaces() });
