Variables: modelling the thing, not the numbers
Drive a model from named variables so one edit resizes the whole part correctly.
The number that appears in eleven places
Your enclosure has 2.4 mm walls. That figure is now typed into the outer extrude, the inner pocket, the lid lip, the screw boss thickness, and six dimensions you have forgotten about. Then you switch to a 0.6 mm nozzle and want 3 mm walls.
You will find eight of the eleven. The other three will produce a lid that does not sit flat, and you will not work out why for an hour.
Variables in Onshape
Add a Variable feature to the feature list, give it a name and a value, and from that point down the tree you can type #name into any dimension field. Variables are scoped to the features below them, so they belong at the very top of the tree.
Three things make them more useful than they first look.
- Units are part of the value.
#wall = 2.4 mmis a length, not a bare number. You can write#wall * 2 + 0.4 mmin a dimension box and it does the right thing. - Any dimension field accepts arithmetic. Even without variables, typing
60 / 3into a length works. With variables you get real expressions. - A Variable Studio shares them across a document. When a box and its lid live in separate Part Studios, one clearance value can drive both, which is precisely the case where a mismatch hurts most.
Name the reason, not the value
#twoPointFour is a variable that has learned nothing. Useful variables are named after why the number exists, and the good ones are usually derived from each other:
#nozzle = 0.4 mm— a fact about your hardware.#wall = #nozzle * 6— walls in whole extrusion widths slice cleanly, with no thin sliver of infill trapped in the middle.#layer = 0.2 mm— the other hardware fact. Heights that are multiples of it land on layer boundaries.#clearance = 0.3 mm— the gap you leave between parts that must fit. Lesson seven is about measuring your own real value for this; when you find it, you will change it here, once.
Configurations, briefly
When you want the same part in several sizes — a phone stand for three phones, a shelf bracket in 40, 60 and 80 mm — do not copy the Part Studio. Use a configuration: expose a variable as an input and Onshape generates the variants from one model, each exportable separately.
Reach for it the second time you catch yourself about to duplicate a document. Not before — configurations on a design that is still moving are a way to be wrong in three sizes at once.
Hands on
Rebuild the bracket on variables
Done when: Changing #nozzle from 0.4 to 0.6 mm updates every wall in the part, and nothing else moves.
- At the very top of the feature list, insert three Variable features:
#nozzle = 0.4 mm,#layer = 0.2 mm,#clearance = 0.3 mm. - Add a fourth below them:
#wall = #nozzle * 6. Onshape evaluates it and shows you 2.4 mm. Variables can reference variables defined above them. - Edit the plate extrude and replace its typed depth with
#wall. Do the same for the upstand thickness. - Edit the hole diameter to
5 mm + #clearance * 2. You have just written down why the hole is oversized instead of quietly baking it in. - Change
#nozzleto0.6 mm. Every wall becomes 3.6 mm and the hole is untouched, because the hole depends on clearance rather than on nozzle width. That separation is the whole skill. - Set it back to 0.4 mm, then rename
#clearanceto something wrong on purpose and watch the dependent dimensions error. Variables are references too, and they break the same way.
Check your recall
Answer from memory — no scrolling back.
Read this next — primary source
Onshape Help — VariableOnshape documentation
Short, exact, and worth reading in full — it covers the naming rules, the units behaviour, and Variable Studios, which is the part most tutorials skip and the part that matters once a document holds more than one Part Studio.
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.