Sketches, constraints, degrees of freedom

Every sketch is a little puzzle with a countdown. Learn to drive it to zero so your geometry stops wandering.

A sketch is a puzzle with a countdown

Draw a line on paper and it is done. Draw a line in CAD and the software sees four unknowns: an x and a y for each endpoint. Those unknowns are degrees of freedom. Until you spend them all, the line is one of infinitely many lines the sketch would accept, and your model will quietly shift the next time anything nudges it.

You spend degrees of freedom in two currencies. Constraints are relationships — this line is horizontal, this endpoint sits on the origin, these two circles share a centre. Onshape calls them the rules that govern how sketch entities relate. Dimensions are numbers — this line is 40 mm long. Both remove freedom; they are not different in kind.

Interactive — degrees of freedom

4

degrees of freedom left

Every press is a different set of values the sketch would happily accept. Add constraints until pressing it changes nothing — that is what “fully defined” means.

The colour tells you, and so does dragging

Onshape draws under-defined geometry in blue and fully defined geometry in black. When everything in a sketch turns black, the sketch has exactly one possible shape.

The colour tells you that something is loose. To find what is loose, use the drag test: click an endpoint, a line, an arc, and try to pull it. Anything that moves still has freedom left. This is the trick experienced users reach for first, and it beats staring at the constraint icons.

The constraints you will use every single day

  • Coincident — a point sits on another point, line, or the origin. The workhorse; most sketches are held together by these.
  • Horizontal / vertical — cheap, obvious, and applied automatically as you draw. Let the inferencing do it.
  • Equal — two lengths or radii track each other. This is how you say “all four mounting holes are the same” once.
  • Concentric — shared centre. Bosses, counterbores, anything round on top of anything round.
  • Tangent — an arc meets a line smoothly. Required for fillets you draw yourself rather than apply as a feature.
  • Midpoint and symmetric — the pair that centres things honestly. Use them instead of typing half of a dimension.

Over-defined is a different problem

If you keep adding after you hit zero, the sketch goes over-defined and Onshape complains. Usually you have told it the same thing twice — a horizontal constraint plus a dimension that only makes sense if the line is horizontal, say — or you have told it two things that cannot both be true. Delete the constraint you added last, not the one that looks guiltiest. The one you added last is almost always the redundant one.

Hands on

Rebuild yesterday's plate, fully defined

Done when: Every line in the sketch is black, dragging moves nothing, and the plate is centred on the origin.

  1. Open your cad-course document and double-click Sketch 1 to edit it.
  2. Select two opposite corners of the rectangle and apply the symmetric constraint about the origin point. The rectangle snaps to centre itself. That is two degrees of freedom bought with one constraint, and it means the plate stays centred at every future size.
  3. Dimension the horizontal edge to 60 mm and the vertical edge to 40 mm. Watch the remaining blue turn black.
  4. Try to drag a corner. Nothing should move. If something does, click it and look at what is still free.
  5. Now change the 60 mm dimension to 90 mm. The plate grows in both directions and stays centred — because you said “centred” as a constraint rather than as arithmetic.
  6. Deliberately break it: add an equal constraint between the two edges. Read the over-defined error, then undo. Seeing the error on purpose once is worth more than meeting it by accident later.

Terms from this lesson — constraint, dimension, degrees of freedom, fully defined — are all pinned down on the glossary page and used with exactly those meanings for the rest of the course.

Check your recall

Answer from memory — no scrolling back.

  1. 1. How many degrees of freedom does a single unconstrained line segment have?
  2. 2. A sketch is entirely black but the whole shape slides when dragged. What is missing?
  3. 3. Why prefer an equal constraint over typing the same number twice?
  4. 4. What does an over-defined sketch usually mean?

Read this next — primary source

Troubleshooting Sketch Constraints

Onshape Learning Center — free, about 30 minutes

It hands you sketches that were deliberately built badly and makes you repair them. Fixing broken constraints teaches the subject far faster than drawing clean ones, and this is the single most useful free course Onshape publishes.

Stuck, curious, or think this lesson is wrong? Ask your teaching agent. That’s the point of the workspace — the lessons are the scaffold, the conversation is where the learning gets unstuck.