How to Fully Constrain a Sketch in FreeCAD
A fully constrained sketch in FreeCAD ensures your 3D models remain robust, predictable, and free from unexpected geometry errors during parametric changes. This article walks you through the essential process of eliminating degrees of freedom using geometric and dimensional constraints within the Sketcher workbench, transforming unconstrained geometry into a stable, fully defined profile ready for 3D operations.
1. Create a Sketch Attached to an Origin
Open the Sketcher workbench or the Part Design workbench. Create a new sketch and select a base plane (such as the XY_Plane). Starting with a defined plane ensures your sketch has a fixed reference orientation relative to the document's global coordinate system.
2. Draw Your Base Geometry
Use the drawing tools (lines, arcs, circles, polygons) to sketch the rough shape of your design. Do not worry about exact dimensions or alignment at this stage. Keep the initial layout as close to the intended design as possible to prevent lines from flipping inside out when constraints are applied.
3. Monitor Degrees of Freedom
Open the Tasks tab on the left panel to view the Solver messages. FreeCAD displays the remaining degrees of freedom (DoF) in your sketch:
- White geometry: Under-constrained (can be moved or resized).
- Green geometry: Fully constrained (locked in position, orientation, and size).
- Orange/Red geometry: Over-constrained or conflicting (contains redundant or contradictory constraints).
Click on the blue link in the Solver message (e.g., "Under-constrained: 4 degrees of freedom") to highlight which elements still have movement.
4. Apply Geometric Constraints First
Geometric constraints define how elements relate to each other without using specific numbers. Always apply these before dimensional constraints:
- Coincident: Join two endpoints or place a point onto a line.
- Point On Object: Lock a point anywhere along a line or curve.
- Horizontal / Vertical: Lock lines to the horizontal or vertical axes.
- Parallel / Perpendicular: Ensure lines run alongside or at 90 degrees to one another.
- Tangent: Create smooth transitions between lines and curves.
- Equality: Make multiple lines the same length or circles the same radius.
- Symmetry: Center elements symmetrically around an axis or reference point.
5. Anchor the Geometry to the Origin
A common reason sketches remain under-constrained is that they float freely in space. You must lock the sketch's position relative to the coordinate center:
- Select a key vertex of your shape and the red origin point \((0,0)\).
- Apply a Coincident constraint to lock a corner directly to the origin, or apply horizontal and vertical distance constraints between the origin and your sketch elements.
6. Apply Dimensional Constraints
Once the general behavior and shape are fixed, lock the physical size using dimensional tools:
- Horizontal Distance / Vertical Distance: Lock precise distances along the grid axes.
- Length / Distance: Lock the direct length of an angled line or the shortest distance between two features.
- Radius / Diameter: Define circle and arc sizes.
- Angle: Define the angular relationship between two intersecting lines.
7. Resolve Over-Constraining and Finish
Add constraints methodically until the Solver message reads: "Fully constrained". When this happens, all sketch lines will turn bright green.
If you accidentally add an unnecessary constraint, the solver will turn orange and report an over-constrained sketch. Simply select the redundant constraint listed in the Solver messages or click on its icon in the 3D view and press Delete.
Once fully constrained, click Close in the Tasks panel to proceed with 3D features such as Pad, Pocket, or Revolve.