FreeCAD US

Sketcher workbench · FreeCAD 0.21 · Part Design

Sketcher Constraints Tutorial: How Geometry Gets Locked

A sketch is only a set of coordinates until constraints define the relationships between its edges. This tutorial records the process stage by stage: how each constraint type behaves, how driving dimensions are applied, how the solver reports its status, and which errors stop a Pad or Pocket from building. Every step is verified against the solver readout before the sketch is closed.

FreeCAD Sketcher canvas with geometric constraint markers on a rectangular profile
Fig. 1: Constraint markers appear along the edges as each relationship is applied to the profile.

Four questions that come up before the first constraint

These are the points that stop most beginners in the first hour. The answers below are the ones the solver itself confirms — nothing here depends on personal preference.

Does the order of constraints matter?

The solver evaluates all constraints at once, but the order of application determines which one is flagged first when a conflict appears. Apply geometric constraints first and dimensional constraints last, so the numeric values attach to geometry that already has a defined shape.

How many constraints does a sketch need?

Exactly as many as it takes to reach zero degrees of freedom. A rectangle typically needs four coincident constraints, two horizontal or vertical constraints and two dimensional constraints. The counter in the task panel reports the remaining degrees of freedom after every operation.

What separates a constraint from a dimension?

A dimension is a constraint that carries a numeric value — a datum constraint. Both consume degrees of freedom in the same way. The difference is that a datum can be edited later or driven from a spreadsheet, while a geometric constraint only states a relationship.

Can an under-constrained sketch be padded?

Yes. Pad and Pocket accept an under-constrained profile, but the geometry keeps moving on recompute and downstream features inherit the shift. The workflow described in the modeling best practices guide treats zero degrees of freedom as the closing condition of every sketch.

What a fully constrained sketch delivers

The constraint set is the contract between the sketch and every feature built on top of it. When the contract is complete, edits propagate predictably and the model survives parameter changes without manual repair. The list below records what is observed when the workflow is followed to the end.

  1. Stable recompute. Geometry returns to the same position after every change of a driving value.
  2. Predictable Pad and Pocket. The profile closes and the feature builds on the first attempt.
  3. Spreadsheet control. A single cell edit updates every dimension bound to it, as described in the parametric spreadsheet workflow.
  4. Clean export. Tessellation for STL and STEP output starts from geometry that does not shift between recomputes.
  5. Readable history. The constraint list documents design intent for anyone opening the file later.

Numbers from the workbench

Constraint tools
19

Geometric and datum constraint tools sit in the Sketcher toolbar.

Target degrees of freedom
0

The value the solver reports for a fully constrained sketch.

Geometry states
3

White for under-constrained, green for fully constrained, red for conflicting.

Constraint types and what each one fixes

Each constraint removes a specific set of degrees of freedom. Applying the right type first reduces the number of dimensional values needed later and keeps the sketch readable. The six groups below cover the majority of profiles built in Part Design.

Coincident

Two points are merged into one. This is the first constraint applied to any closed profile, because it joins the endpoints of separate line segments into a continuous wire. Without it, the sketch remains a collection of disconnected edges.

Horizontal and vertical

The edge is aligned to the sketch axes. These two constraints remove one degree of freedom each and replace most angular dimensions. A rectangle built from four lines needs two of them plus the coincident set to stop rotating.

Parallel and perpendicular

The angle between two edges is fixed at 0° or 90°. The solver keeps the relationship when either edge moves, which is what allows a profile to be reshaped without breaking its structure. Both constraints operate on lines and on construction geometry.

Tangent

A line touches an arc or circle at exactly one point, and two curves meet with a shared tangent direction. Tangency is applied to fillets, slots and blend profiles. It is the constraint most often applied twice by mistake, which produces a redundant message.

Equal

Two lines receive the same length, or two arcs the same radius. One dimension then controls both elements, which halves the number of values in symmetric profiles. Editing the single datum resizes every element in the equal set at once.

Symmetric, block and lock

Symmetric mirrors two points about a line or axis. Block freezes existing geometry, and lock fixes a point to a fixed coordinate pair. These three are used sparingly: they remove freedom without describing intent, and they make later parametric edits harder to trace.

The complete toolbar walkthrough with screenshots continues in the constraints tutorial reference, and the beginner guide covers the interface layout before the first sketch is opened.

Dimensioning: driving values and reference values

Dimensional constraints are applied after the geometric set is complete. Each datum removes one remaining degree of freedom and stores a value that can be edited in the constraint list or bound to a spreadsheet cell. The distance tools measure between points, between a point and a line, or between two parallel edges; the radius and diameter tools apply to arcs and circles.

A datum can be switched to reference mode, where it displays a measurement without constraining anything. Reference dimensions are useful while a profile is still being shaped, because they report the current value without consuming freedom. The switch sits in the constraint dialog and is reversible at any time.

Order of operations that holds up

  • Close the wire with coincident constraints on all endpoints.
  • Apply horizontal, vertical, parallel, perpendicular and tangent relationships.
  • Add equal constraints wherever a repeated value is intended.
  • Apply driving dimensions last, starting with the largest overall size.
  • Check the degrees-of-freedom counter after every datum.
Dimension toolbar and numeric input field in a CAD sketcher
Fig. 2: A datum dialog records the value and removes one degree of freedom on confirmation.

A dimension that is edited twice in one session usually indicates a missing geometric constraint. The geometric relationship should carry the intent; the number should only carry the size.

Solver messages panel showing degrees of freedom and constraint status
Fig. 3: The solver messages block reports degrees of freedom and lists every flagged constraint.

Reading the solver status

The solver runs continuously and reports its result in two places: the geometry color on the canvas and the message block in the task panel. White edges indicate remaining freedom, green edges indicate a fully constrained sketch, and red edges indicate a conflict that must be resolved before the sketch can close.

The message block lists the exact number of degrees of freedom and names any redundant or conflicting constraints by index. That index corresponds to the position in the constraint list, so selecting the entry highlights the offending geometry on the canvas. Resolving the flagged item and recomputing is the standard repair step.

Under-constrained

The counter shows a positive number. Geometry can still be dragged, and the profile is not ready for production use.

Fully constrained

The counter shows zero and the edges turn green. Dragging no longer changes the shape.

Common solver errors and how they are cleared

Four messages account for nearly every blocked sketch. Each one names a specific structural problem, and each one is cleared by removing or reordering constraints rather than by adding new geometry.

Message Cause Resolution
Redundant constraints The same relationship is stated twice, for example a horizontal constraint on an edge that is already parallel to a horizontal one. Delete the later entry from the constraint list and recompute.
Conflicting constraints Two constraints demand incompatible positions, such as a fixed length and a tangent that cannot both hold. Remove the more recent constraint and re-apply it after the geometry is adjusted.
Wire is not closed Two endpoints are near each other but not joined by a coincident constraint. Select both points and apply coincident, then verify the profile closes.
Self-intersecting wire Edges cross each other, which prevents Pad from generating a solid. Move the crossing vertex and re-apply the affected constraints.

When the sketch closes cleanly, the next stage is the feature itself — the Pad and Pocket walkthrough covers depth, direction and mid-plane options in detail.

Practice drill: a constrained mounting bracket profile

The drill builds a bracket outline with four holes and a central slot. It is small enough to finish in one sitting and it exercises every constraint group covered above. The sequence below is recorded in the order it is performed, with the expected solver reading after each stage.

  1. Outline. Draw four lines roughly forming a rectangle and apply coincident to each corner. Expected reading: 8 degrees of freedom.
  2. Orientation. Apply horizontal to the top and bottom edges, vertical to the sides. Expected reading: 4 degrees of freedom.
  3. Overall size. Add a horizontal distance and a vertical distance between opposite corners. Expected reading: 2 degrees of freedom.
  4. Position. Lock the lower-left corner to the origin with a coincident constraint on the sketch axes. Expected reading: 0 degrees of freedom, edges turn green.
  5. Holes. Add four circles, apply equal to the set, then one radius datum and symmetric placement about the vertical axis.
  6. Slot. Build the slot from two arcs and two lines, apply tangent at each junction, and constrain the arc centres with a horizontal distance.

When the profile reports zero degrees of freedom, close the sketch and pad it. The finished part is then ready for the STL and STEP export routine, where the mesh deviation value determines how closely the printed surface follows the original curves.

Continue with the next stage of the workflow

Constraints close the sketch; features build the part. Move on to the Pad and Pocket operations, or review the export settings that determine mesh quality for 3D printing and CNC toolpaths.