Skip to main content

Offset

Offset makes a surface at a constant distance from faces: a skin standing clear of a body, a second wall parallel to a surface, the inside of a cover with room for what it covers. With a distance of 0 it copies the faces where they are. The faces you offset are not changed; the result is a surface of its own.

This is the Surfaces menu's Offset. The Curves menu's Offset runs a curve along faces, and the sketch toolbar's Offset offsets sketch geometry. All three write offset(…); how the statement is written tells them apart (see In code).

In the viewport​

  1. Open the Surfaces menu on the toolbar and click Offset. The Offset surface dialog opens with the Faces row armed (blue border).
  2. Click the faces to offset. A click on a face takes that face, of a solid or of a surface; a surface that is a single face, such as an extruded line, is taken whole, as its row in the timeline takes any surface.
  3. Set the Distance. As soon as the row holds a pick, the surface previews in green on the side it goes to.
  4. Click Apply. The timeline gains an Offset Surface row, and in the Shapes panel a Surface appears beside the body you offset.
The Offset surface dialog with the four side faces of a block picked, distance 2
  1. 1
    Faces
    What to offset. Takes several picks: faces of solids and of surfaces, and whole surfaces. Click a chip’s ✕ to drop it.
  2. 2
    Distance
    A number or an expression. Positive goes along the faces’ normals, negative against them; 0 copies the faces.
  3. 3
    Apply
    Writes offset(distance, faces). Exit closes the dialog without writing anything.
  4. 4
    Statement
    The statement Apply will write, updated as you pick.

The four side faces of a block, double-clicked into the row as one group and offset 2:

A sleeve standing 2 clear of the four walls of a block

The code behind it

The dialog names faces of a solid with a selector, here block.sideFaces(), and gives the block's statement a variable if it has none. It names the statement Offset Surface n.

block.part.js
import { sketch, line, extrude, offset, color } from 'fluidcad/core';
import { coincident, distance, fix, horizontal, vertical } from 'fluidcad/constraints';

// A 40 x 30 block, 20 high.
sketch('xy', () => {
const a = line([0, 0], [40, 0]);
const b = line([40, 0], [40, 30]);
const c = line([40, 30], [0, 30]);
const d = line([0, 30], [0, 0]);
coincident(a.end(), b.start());
coincident(b.end(), c.start());
coincident(c.end(), d.start());
coincident(d.end(), a.start());
horizontal(a);
vertical(b);
horizontal(c);
vertical(d);
fix(a.start(), [0, 0]);
distance(a.start(), a.end(), 40);
distance(b.start(), b.end(), 30);
});
const block = extrude(20);

// Surfaces › Offset: the four side faces of the block, moved 2 along their
// normals. The faces of a solid point out of the material, so a positive
// distance goes outward: a sleeve standing 2 clear of the walls. Where two
// walls meet, their offsets are extended to meet again. The block is not
// changed; the sleeve is a surface of its own.
const sleeve = offset(2, block.sideFaces());

// Painted only so the picture tells the sleeve from the block.
color('#5b9bd5', sleeve);

Faces or surfaces selected before you click Offset fill the Faces row. The selection goes in whole or not at all: with an edge or a vertex among it, the row opens empty.

Which side​

A positive distance goes along the faces' normals, a negative one against them:

  • Faces of a solid point out of the material, so a positive distance goes outward, away from the solid, and a negative one into it.
  • A surface points the way it was made. For a surface extruded from a sketch, positive is to the left of each curve as it was drawn, seen from the side the extrusion goes to. An imported surface points wherever the file made it point.

The preview shows the side before you apply. The block's side faces, with each distance:

Distance 2Distance 2 modeoffset(2, block.sideFaces())

Outward: a sleeve 2 clear of the walls.

Distance −2Distance −2 modeoffset(-2, block.sideFaces())

Inward: 2 inside the walls, through the block.

Distance 0Distance 0 modeoffset(0, block.sideFaces())

A copy of the walls, lying exactly on them.

A distance of 0 copies the faces into a surface of their own, with geometry of its own: moving or changing the copy leaves the faces where they were. Use it to keep a face of a solid as a surface, to thicken or to cut with.

A curved face has a limit on its inside: an offset larger than the tightest bend there would fold over itself. The dialog then says so instead of drawing a preview (see Errors); offset to the other side, or give a smaller distance.

A whole surface​

The timeline row of a surface takes it whole. Its faces move together, and stay joined as they were:

A ribbon surface and a second ribbon 6 inside its bend

The code behind it

The dialog writes const s = … on a surface statement no variable names, so it can hand the surface to offset.

ribbon.part.js
import { sketch, line, arc, extrude, offset, color } from 'fluidcad/core';
import { coincident, distance, fix, horizontal, radius, tangent, vertical } from 'fluidcad/constraints';

// An open profile: a line, an arc and a line drawn end to end.
const profile = sketch('xy', () => {
const a = line([0, 0], [30, 0]);
const b = arc([30, 0], [50, 20], [30, 20]);
const c = line([50, 20], [50, 45]);
coincident(a.end(), b.start());
coincident(b.end(), c.start());
tangent(a, b);
tangent(b, c);
horizontal(a);
vertical(c);
fix(a.start(), [0, 0]);
distance(a.start(), a.end(), 30);
radius(b, 20);
distance(c.start(), c.end(), 25);
});

// The profile extruded 25 up on the Surface tab: a ribbon of three faces.
const ribbon = extrude(25, profile).surface();

// Surfaces › Offset with the ribbon picked whole: a second ribbon 6 away,
// on the ribbon's own side (the left of each curve as it was drawn, seen
// from above: into the bend). The arc's radius shrinks from 20 to 14; the
// flat faces move 6 and stay tangent to it. The source ribbon stays.
const inner = offset(6, ribbon);

color('#5b9bd5', inner);

Faces that meet at an edge​

Faces of one body that share edges make one surface. Where they meet smoothly, as a line and an arc tangent to it do, each face simply moves. Where they meet at a sharp edge, the moved faces would leave a gap outside the edge and cross inside it, so they are extended or trimmed until they meet again: the surface has no gaps and no overlaps. A free-form face that cannot be extended that far gets a round face over the outside of the edge instead. The top of a block and the two walls at one corner, offset 4, seen from behind:

Three faces of a block offset 4 into one surface that closes over the corner

The code behind it
block.part.js
import { sketch, line, extrude, offset, color } from 'fluidcad/core';
import { coincident, distance, fix, horizontal, vertical } from 'fluidcad/constraints';

// A 40 x 30 block, 20 high.
sketch('xy', () => {
const a = line([0, 0], [40, 0]);
const b = line([40, 0], [40, 30]);
const c = line([40, 30], [0, 30]);
const d = line([0, 30], [0, 0]);
coincident(a.end(), b.start());
coincident(b.end(), c.start());
coincident(c.end(), d.start());
coincident(d.end(), a.start());
horizontal(a);
vertical(b);
horizontal(c);
vertical(d);
fix(a.start(), [0, 0]);
distance(a.start(), a.end(), 40);
distance(b.start(), b.end(), 30);
});
const block = extrude(20);

// The top face and the front and right side faces, the three that meet at
// the front-right corner, offset 4 outward. Each argument is one pick of the
// dialog. The faces meet at sharp edges, so their offsets are extended until
// they meet again: one surface of three faces, closed at the corner. The
// picture looks from behind, where the cap stands 4 clear of the block.
const cap = offset(4, block.endFaces(), block.sideFaces(2, 3));

color('#5b9bd5', cap);

Faces of different bodies, or faces of one body that do not touch, give one surface each.

What a click takes​

You clickThe row takesWritten as
A face of a surface, in the viewportThat faceA selector, such as s.sideFaces(1)
The face of a surface that is a single face, such as an extruded lineThe whole surfaceIts variable, s
The timeline row of a surfaceThe whole surface: every face, and every surface the statement holdsIts variable
A face of a solidThat faceA selector, such as block.sideFaces(face().…)

On a face, double-click to take the whole group it belongs to, such as every side face of an extrude, or right-click for a menu of its groups (its tangent faces, the faces of the feature that made it); hover an item to preview it, click it to add it. Each pick is an argument of its own: offset(2, s, block.endFaces()). A solid's timeline row is not taken: pick its faces.

A face of a surface a split cut in pieces is written through the split: the face that is a whole piece as offset(8, sp2.back()), the split bound to a variable when it has none. The split's timeline row takes every piece.

What becomes of the faces​

Nothing: the solid or the surface you offset stays as it is, in the model and on screen, and later statements read it as before. The offset is a new surface beside it.

Thicken an offset​

An offset surface is a surface like any other: thicken it into a solid, intersect or project curves on it, export it. The side faces of a block, offset 1 and thickened 2 outward, make a collar that slides over the block with 1 of clearance:

A collar 2 thick standing 1 clear of the walls of a block

The code behind it
block.part.js
import { sketch, line, extrude, offset, thicken, color } from 'fluidcad/core';
import { coincident, distance, fix, horizontal, vertical } from 'fluidcad/constraints';

// A 40 x 30 block, 20 high.
sketch('xy', () => {
const a = line([0, 0], [40, 0]);
const b = line([40, 0], [40, 30]);
const c = line([40, 30], [0, 30]);
const d = line([0, 30], [0, 0]);
coincident(a.end(), b.start());
coincident(b.end(), c.start());
coincident(c.end(), d.start());
coincident(d.end(), a.start());
horizontal(a);
vertical(b);
horizontal(c);
vertical(d);
fix(a.start(), [0, 0]);
distance(a.start(), a.end(), 40);
distance(b.start(), b.end(), 30);
});
const block = extrude(20);

// The side faces offset 1 outward: where the inside of a collar goes, with
// 1 of clearance all round.
const sleeve = offset(1, block.sideFaces());

// Surfaces › Thicken the offset 2 outward, kept apart from the block: a
// collar 2 thick that slides over it.
const collar = thicken(2, sleeve).new();

color('#5b9bd5', collar);

Editing​

Double-click the Offset Surface row in the timeline. The view rolls back to just before the statement and the dialog reopens: one chip per face argument, as written, and the Distance as written. A statement that names no faces, and so offsets the select(…) written before it, opens on a Current: last selection chip, the selection lit in the viewport.

A chip's ✕ takes an argument off and a pick adds one after the others; the arguments you leave are written back exactly as they were. On Current: last selection, a pick starts from the selected faces: it adds a face to them or takes one off, and the faces are then written into the statement. Apply rewrites only what you changed: a new distance leaves the faces as written. A statement written in a form the dialog cannot hold opens no dialog: a message says why, and you edit it in the source.

In code​

import { offset } from 'fluidcad/core';

offset(2, block.sideFaces()); // 2 outward from the walls of a solid
offset(-1, select(face().cylinder())); // 1 into a solid, from its round faces
offset(0, block.endFaces()); // a copy of the top and bottom, as a surface
offset(3, s); // a whole surface, 3 to its own side
offset(2, block.endFaces(), s); // several arguments, each its own pick
offset(2, [a, b]); // or one list
ArgumentTakes
distanceA length or an expression. Positive goes along the faces' normals, negative against them, 0 copies the faces.
...facesFaces of solids or of surfaces (block.sideFaces(), select(face()…)), whole surfaces, whole solids (all their faces), or lists of those.

With no faces given, the select(…) written just before the statement is offset. The tool has no options and no chained methods.

offset has three meanings; where and how the call is written decides which:

WrittenMeaning
inside a sketch() callbackthe sketch offset of sketch geometry
outside a sketch, with { on }an offset curve along faces
outside a sketch, without { on }an offset surface, this page

The result names its faces and its open rim:

const os = offset(2, block.sideFaces());

os.faces() // every face of the result
os.boundaryEdges() // the open rim: the edges that bound one face only

Each takes an index or a filter: os.faces(0), os.boundaryEdges(edge().line()).

Errors​

SituationMessage
Edges, a curve or a sketch given as the facesoffset: these are edges. Hint: To offset a curve along faces write offset(d, edges, { on: faces }).
The distance reaches past the faces' tightest bend on the side it goes tooffset: the distance is larger than the faces' tightest bend allows on this side.
The kernel cannot offset the faces soundly, such as walls moved inward past each otheroffset: could not offset these faces (…what went wrong…).
No faces given, and no select(…) just beforeoffset: outside a sketch, give the faces to offset.
The faces argument matches no faceoffset: the faces argument holds no faces.
The distance is not a numberoffset: the distance must be a number; got '2'.

The dialog refuses an empty or unreadable distance before it asks the engine: Enter a distance. The other refusals show in the dialog in place of the preview, in the words above.

Offsetting faces before this version​

Outside a sketch, offset(distance, faces) used to trace the outline of flat faces, offset in their plane, as edges to extrude:

// The old meaning: the top face's outline, grown by 3, raised 5.
const rim = offset(3, body.endFaces());
extrude(5, rim);

It now makes the offset surface this page describes. So that a model written for the old meaning does not quietly turn into something else, an extrude, cut, revolve or sweep of an offset of flat, coplanar faces is refused for now, whether it names the offset (extrude(5, rim)) or, written without a profile, follows it (offset(3, body.endFaces()); extrude(5);). The error shows on the extrude's row:

offset(distance, faces) now makes an offset surface, not an outline to extrude. Hint: For the old result, sketch on the face and offset its projection, kept out of the profile: sketch(face, () => { offset(d, project(face).guide()) }), then extrude.

The old outline is the face's projection, offset in a sketch on the face. Mark the projection .guide() so that only the offset makes the profile:

sketch(body.endFaces(), () => {
offset(3, project(body.endFaces()).guide());
});
extrude(5);

The old call also shrank the face's holes as it grew its outline, where a sketch offset grows every loop it is given. For a face with holes the hint gives the outer loop and the holes as two offsets, by d and by -d:

Hint: For the old result, sketch on the face and offset the projections of its outer loop by d and of its holes by -d, kept out of the profile: const outer = select(edge().outerOf(face)), holes = select(edge().holeOf(face)); sketch(face, () => { offset(d, project(outer).guide()); offset(-d, project(holes).guide()) }), then extrude.

A plate with a hole, its outline grown by 3 and its hole shrunk by 3, raised 5, as the old call gave it:

A plate with a hole and a raised rim 3 wider all round, its hole 3 narrower

The code behind it
plate.part.js
import { sketch, line, circle, extrude, offset, project, select } from 'fluidcad/core';
import { coincident, diameter, distance, fix, horizontal, vertical } from 'fluidcad/constraints';
import { edge } from 'fluidcad/filters';

// A 40 x 40 plate, 10 thick, with a hole of diameter 16 in its middle.
sketch('xy', () => {
const a = line([0, 0], [40, 0]);
const b = line([40, 0], [40, 40]);
const c = line([40, 40], [0, 40]);
const d = line([0, 40], [0, 0]);
const hole = circle([20, 20], 16);
coincident(a.end(), b.start());
coincident(b.end(), c.start());
coincident(c.end(), d.start());
coincident(d.end(), a.start());
horizontal(a);
vertical(b);
horizontal(c);
vertical(d);
fix(a.start(), [0, 0]);
distance(a.start(), a.end(), 40);
distance(b.start(), b.end(), 40);
diameter(hole, 16);
fix(hole.center(), [20, 20]);
});
const plate = extrude(10);

// The outline of the top face grown by 3 and its hole shrunk by 3, raised 5:
// what `extrude(5, offset(3, plate.endFaces()))` used to give. The outer
// loop and the hole are offset apart, each by its own sign, and the
// projections are guides so that only the offsets make the profile.
const outer = select(edge().outerOf(plate.endFaces()));
const holes = select(edge().holeOf(plate.endFaces()));
sketch(plate.endFaces(), () => {
offset(3, project(outer).guide());
offset(-3, project(holes).guide());
});
extrude(5);

The check looks only at offsets of flat faces lying in one plane, the shape the old idiom always had: an offset of curved faces is not refused.

See also​

  • Before: the faces to offset, of a solid or of a surface
  • After: thicken the offset into a skin of material, trim it, or intersect and project curves on it