FreeCAD Horizontal Distance Constraint Explained

This article provides an overview of the horizontal distance constraint in FreeCAD’s Sketcher workbench, explaining its primary functions, practical applications, and behavior. You will learn how this tool locks horizontal dimensions between sketch elements, how it differs from standard distance constraints, and how it helps eliminate degrees of freedom to achieve fully constrained sketches in parametric 3D modeling.

What Is the Horizontal Distance Constraint?

The horizontal distance constraint in FreeCAD restricts the distance between two points, or the horizontal span of a line, strictly along the sketch's horizontal (X) axis. Regardless of how far apart the selected points are vertically, this constraint forces their horizontal separation to remain at a fixed numerical value or parametric formula.

In the FreeCAD interface, it is represented by a red dimensional line marked with a horizontal dimension symbol (shortcut key: Shift + H).

Primary Functions and Use Cases

1. Dimensioning Horizontal Lengths

When applied to a single line, the horizontal distance constraint fixes the line's length along the horizontal plane. If the line is already constrained to be horizontal, this functions as the total length of the line. If the line is angled, the constraint fixes the width of its bounding box rather than its actual Euclidean length.

2. Spacing Between Distinct Points

The tool can be applied to any two points, such as:

  • The endpoints of two separate lines.
  • The centers of circles or arcs (useful for defining center-to-center hole spacing).
  • A sketch vertex and the sketch origin or a reference axis.

This ensures that the two entities maintain a precise horizontal offset, even if their vertical positions shift during editing.

3. Positioning Elements Relative to the Origin

To fully constrain a sketch, features must be anchored in space. Applying a horizontal distance constraint between a feature’s vertex and the vertical sketch axis (or origin) locks the feature’s horizontal coordinate without restricting its vertical movement.

Difference Between Horizontal Distance and Other Constraints

Understanding how the horizontal distance constraint compares to related constraints helps avoid over-constraining or distorting a sketch:

  • Standard Distance Constraint (Length): Measures the direct, straight-line distance between two points, regardless of angle. If the points move vertically or horizontally, the overall diagonal distance remains unchanged.
  • Horizontal Distance Constraint: Ignores vertical separation entirely and only measures the projected distance along the X-axis.
  • Horizontal Constraint: Simply forces an existing line segment to be parallel to the horizontal axis without defining how long it is.

Parametric Flexibility

Like most dimensional constraints in FreeCAD, the value assigned to a horizontal distance constraint does not need to be a static number. It supports:

  • Mathematical formulas: Calculating spacing dynamically (e.g., Length / 2).
  • Spreadsheet aliases: Driving dimensions externally from a FreeCAD Spreadsheet workbench.
  • Named parameters: Linking to dimensions from other sketches or 3D features.

Using the horizontal distance constraint properly ensures that sketches remain predictable, stable, and easily adjustable throughout the design process.