Skip to main content

Translate

translate() moves solids by a distance along the world axes, or adds a moved copy.

In the viewport​

  1. Click Translate on the toolbar. The Translate dialog docks on the right.
  2. Pick the tab: Move moves the solids; Copy keeps the originals and adds moved copies.
  3. Click the solids to move — any face or edge click in the viewport selects the whole solid, or click their timeline rows. They fill the Solids slot as numbered chips, and the transform gizmo appears at their center.
  4. Drag the gizmo: an arrow moves along its axis, a square within its plane, the center ball in the view plane. Hold Shift on an arrow or a square to move in whole units. A translucent ghost of the moved solids follows the drag, and on release the Distance (X, Y, Z) fields take the new values — an axis the drag left alone keeps what it had, an expression included.
  5. For an exact value, click an arrow and type its distance — a number, an expression, or name = value to declare a variable — or type into the fields. Click Apply.

Escape during a drag puts the gizmo back where the drag started; the next Escape closes the dialog. Double-clicking a translate() row in the timeline reopens it: the model rolls back to just before the statement, with the gizmo where its solids land.

In an assembly, instances are moved with the same gizmo, and the pose is written back as .translate() on the insert() statement.

A spacer slid along the plate onto its stud

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

// A base plate with a stud, and a spacer that has to slide onto the stud.
sketch("xy", () => {
const b = line([-50, -30], [50, -30]);
const r = line([50, -30], [50, 30]);
const t = line([50, 30], [-50, 30]);
const l = line([-50, 30], [-50, -30]);
coincident(b.end(), r.start());
coincident(r.end(), t.start());
coincident(t.end(), l.start());
coincident(l.end(), b.start());
horizontal(b);
vertical(r);
horizontal(t);
vertical(l);
fix(b.start(), [-50, -30]);
distance(b.start(), b.end(), 100);
distance(r.start(), r.end(), 60);
});
const plate = extrude(8);

// The stud, on the plate's top face at x = 30.
sketch(plate.endFaces(), () => { circle([30, 0], 10); });
extrude(30);

// The spacer: a ring modelled at x = -30, a separate body.
sketch(plate.endFaces(), () => {
circle([-30, 0], 24);
circle([-30, 0], 10);
});
const spacer = extrude(8).new();

// Slide the spacer 60 along X onto the stud. translate() names its targets
// (or takes the last object) and adds a step to the timeline.
translate(60, 0, 0, spacer);

Code forms​

import { translate } from 'fluidcad/core';

translate(x) // along X only
translate(x, y) // along X and Y
translate(x, y, z) // all three
translate([x, y, z]) // the same, as a point

translate(x, y, z, a, b) // move specific solids
translate(x, y, z, true) // COPY: keep the original, add a moved duplicate
translate([x, y, z], true, target) // copy a specific solid

The trailing targets are optional; without them translate() moves the object built last. The boolean before the targets switches from moving to copying. Distances are in the file's unit.

Positioning parts​

Translating a part inside its own file is rarely what you want: a part is authored around its own origin and placed when it is inserted into an assembly. Use translate() for placing bodies relative to each other within one part — a second body kept separate with .new(), an imported STEP file (load()), a primitive.

const l = load("bracket")
rotate("x", 90)
translate(0, -50, 25)