Skip to main content

Line

A straight segment between two points. Lines are the sides of almost every profile, and the entities most constraints act on.

In the viewport

  1. Click Line on the sketch toolbar.
  2. Click the start point, then the end point. Each click can be typed instead: the X / Y pill takes exact coordinates, and the body pill takes the length.
  3. Near-horizontal and near-vertical lines snap to the axis and get a horizontal / vertical constraint; a start that snaps onto an existing vertex gets a coincident (both under Auto-constraints; hold Ctrl to skip one).

Polyline chains segments: each new segment starts where the previous one ended, with the junction coincident written for you. Press Space to cycle the segment mode — Line, A-Line (a line at a typed angle to the previous segment), Arc, T-Arc (tangent to the previous segment) and T-Line (a line tangent to the previous arc). Esc ends the chain.

An L-bracket outline built from six lines

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

sketch("xy", () => {
// An L-bracket outline: six lines drawn corner to corner. The
// coordinates are guesses; nothing joins consecutive lines until a
// constraint says so.
const base = line([0, 0], [80, 0]);
const toe = line([80, 0], [80, 15]);
const shelf = line([80, 15], [15, 15]);
const inner = line([15, 15], [15, 60]);
const top = line([15, 60], [0, 60]);
const back = line([0, 60], [0, 0]);
// The Polyline tool writes these when each new line starts on the
// previous end (Auto-constraints); by hand you write them yourself.
coincident(base.end(), toe.start());
coincident(toe.end(), shelf.start());
coincident(shelf.end(), inner.start());
coincident(inner.end(), top.start());
coincident(top.end(), back.start());
coincident(back.end(), base.start());
// Square the bracket up and give it its two leg lengths and thickness.
horizontal(base);
vertical(toe);
horizontal(shelf);
vertical(inner);
horizontal(top);
vertical(back);
fix(base.start(), [0, 0]);
distance(base.start(), base.end(), 80);
distance(back.start(), back.end(), 60);
distance(toe.start(), toe.end(), 15);
distance(top.start(), top.end(), 15);
})

By hand

line(start, end)

line([0, 0], [100, 0]) draws from the first point to the second. The coordinates are guesses: where no constraint applies they stay put; where one does, the solver moves the endpoints.

Nothing joins consecutive lines by itself. Without the coincident statements above, dragging one line would tear the corner open.

Accessors

AccessorMeaning
l.start()The start point
l.end()The end point
l.mid()The midpoint — accepted by coincident() only, where it lowers to a midpoint constraint

The line itself is a target for horizontal, vertical, parallel, perpendicular, tangent, equal, collinear, distance and angle.

Modifiers

line([0, 0], [100, 100]).guide() // construction geometry — see Guides
line([0, 0], [100, 0]).name('base') // name the statement for the timeline