All posts

SOLIDWORKS · equations

SOLIDWORKS global variables and equations: drive a part from a few numbers

Name the five numbers that define the part, link every driving dimension to them, and the next change is one edit.

To drive a SOLIDWORKS part from a few named numbers, open Tools > Equations, add each number as a global variable (for example "plate_length" = 120mm), then set each driving dimension equal to its variable. Change the variable and every linked dimension follows on the next rebuild, so the part changes the way you meant it to.

This guide covers when to use global variables, linked values or a design table, how to set variables up so other engineers can read them, the expressions that are worth knowing, and the mistakes that make an equation-driven part fragile.

Global variables, linked values or a design table?

SOLIDWORKS gives you three ways to tie dimensions together. They overlap, so pick one on purpose.

  • Global variables and equations live in the part, in the Equations folder at the top of the FeatureManager design tree. Use them for the handful of numbers that define the part: overall length, plate thickness, hole size, hole count, wall. One part, one set of values.
  • Linked values (right-click a dimension and choose Link Values) make two or more dimensions share one name and value. They are quick, but the shared value is hidden in the dimensions themselves. Most teams now prefer global variables for anything another person will edit.
  • Design tables drive configurations from an Excel sheet. Use them when one file must hold a family of sizes. A design table can still read dimensions that equations drive, so variables first and a table later is a normal path. See design tables and configurations.
A good test: if the number would appear in a sentence about the part ("a 120 by 80 plate, 10 thick, four M6 holes"), it should be a global variable. Fillet radii on cosmetic edges usually should not.

Set up global variables step by step

1. Open the Equations dialog

Choose Tools > Equations, or right-click the Equations folder in the design tree and choose Manage Equations. If the folder is not visible yet, it appears once the part has its first equation; the Tools menu always works. The dialog has three sections: Global Variables, Features (for suppression states) and Equations. The view buttons at the top switch between the equation view, the sketch equation view, the dimension view and the ordered view.

2. Add the variables with units

Under Global Variables, click the empty name cell and type a name, then the value. Type the unit with every length and angle: 120mm, 30deg. A count such as a hole count has no unit. Without a unit, SOLIDWORKS uses the document units, which is how a part made in millimetres ends up 25.4 times too large when someone opens a template set to inches.

Example: a base plate driven by five variables
NameValueWhat it drives
plate_length120mmLong side of the base sketch
plate_width80mmShort side of the base sketch
plate_thickness10mmExtrude depth
hole_edge12mmHole centre to plate edge
hole_diameter6.6mmClearance hole for M6, ISO 273 medium

Spell names out. plate_length tells the next engineer what it is; L1 does not. Use letters, digits and underscores, start with a letter, and keep one naming style across the company so a search for hole_ finds every hole variable.

3. Link the driving dimensions

Double-click a dimension in the model. In the Modify box, type =, and SOLIDWORKS offers a list with Global Variables, Functions and File Properties. Pick the variable and press the green check. The dimension now shows a Σ in front of its value, which means an equation drives it, and a matching row appears in the Equations section, for example "D1@Sketch1" = "plate_length".

Before you link, rename the dimension. Select it, and in the Dimension PropertyManager change the name in the Primary Value box from D1 to something like length. The equation then reads "length@Base sketch" = "plate_length", which survives the day someone reorders the sketch.

4. Use expressions, not hand-typed copies

A value that depends on another value should say so. Some patterns that come up on almost every plate or bracket:

  • Centred features: "plate_length" / 2 for a hole on the centreline.
  • Hole pitch from edge distance: "plate_length" - 2 * "hole_edge".
  • Counts: int("plate_length" / 40) for one hole roughly every 40 mm; the int function keeps the count whole.
  • Conditions: iif("plate_length" > 200mm, 6, 4) picks six holes on a long plate and four on a short one. The function list in the Modify box shows the exact names your version supports.

Variables can use other variables, so hole_pitch = "plate_length" - 2 * "hole_edge" as its own global variable is often clearer than repeating the expression in three dimensions.

5. Rebuild and check

Press OK. With Automatically rebuild ticked in the dialog, the model updates as you edit; otherwise press Ctrl+B, or Ctrl+Q for a full rebuild. Then change one variable to an extreme value (double the length, halve it) and check that the part still rebuilds without warnings. A part that only rebuilds at the values you designed it at is not really parametric.

Controlling features with equations

The Features section of the dialog can set a feature's suppression state from an expression. For example, a lightening pocket can be suppressed when the plate is short: set the pocket's state to iif("plate_length" < 150mm, "suppressed", "unsuppressed"). Use this sparingly. A tree full of conditional features is hard to review, and a feature that is suppressed most of the time still has to rebuild correctly when it comes back.

Equations in assemblies

An assembly can have its own global variables and can drive part dimensions from them. That creates an external reference: the part now depends on the assembly being open and in the right state. For a part used in one assembly that can be acceptable. For a part reused across products, keep its variables in the part and change them there. If you must link across files, the Equations dialog can also link to an external text file (Link to external file), which several parts can share without depending on each other.

Common mistakes and how to fix them

  • A circular equation. a = b + 1 and b = a - 1 cannot be solved. SOLIDWORKS flags it in the dialog. Decide which value is the input and make the other one depend on it.
  • Editing a driven dimension. A dimension with Σ is driven by an equation; typing a new number in it either breaks the link or is refused. Change the variable instead.
  • Missing units. Mixed templates turn 120 into 120 inches. Always type the unit.
  • Equations on sketch dimensions that do not update. An equation that references another sketch dimension may not update while you are still in the sketch. Exit the sketch and rebuild. Driving from global variables avoids most of this.
  • A variable that drives nothing. Leftovers from an old version confuse the next person. Delete them, or the tree will tell a story that is no longer true.
  • A number typed by hand that equals a variable. If a dimension reads 12 and hole_edge is 12, it will silently stop matching the first time someone changes the variable. Link it.

A worked example: the base plate

  1. Create the five variables from the table above.
  2. Sketch a corner rectangle on the Top Plane, starting at the origin. Rename its two dimensions length and width and link them to plate_length and plate_width. The sketch is fully defined and anchored to the origin.
  3. Extrude it and rename the feature Base plate. Rename the depth dimension and link it to plate_thickness.
  4. Sketch one circle on the top face, dimension its centre hole_edge from two edges, link the diameter to hole_diameter, and cut through all. Rename the cut Mounting hole.
  5. Add a linear pattern in two directions with spacing "plate_length" - 2 * "hole_edge" and "plate_width" - 2 * "hole_edge", two instances each.
  6. Set plate_length to 200mm and rebuild. The holes move with the corners; nothing else needs editing.

That is the whole value of the method: the next change is one number, and the person making it does not need to know how the part was built.

Checklist before you hand the part over

  • Every number in the part's one-line description is a global variable with a spelled-out name and a unit.
  • Every driving dimension shows Σ, and no dimension repeats a variable's value by hand.
  • No variable is left that drives nothing.
  • Sketches are fully defined and anchored to the origin, so a changed variable moves geometry predictably. See design intent and a clean feature tree.
  • The part rebuilds without warnings at the smallest and largest values you expect.

For hole sizes, use the standard rather than a remembered number: the clearance and counterbore holes guide lists the ISO 273 values. To see how a first request works in the Flair pane, read your first request.

Questions

Where are global variables in SOLIDWORKS?

In the Equations dialog: Tools > Equations, or right-click the Equations folder at the top of the FeatureManager design tree and choose Manage Equations. Global variables are the first section of that dialog.

What does the Σ symbol on a dimension mean?

An equation drives that dimension. Change the global variable or the equation it points to, not the dimension itself.

Should I type units in SOLIDWORKS equations?

Yes. Write 120mm or 30deg. Without a unit SOLIDWORKS uses the document units, and a part opened with a different template can change size.

Global variables or linked values?

Use global variables for numbers other people will edit: they are listed in one place with names. Linked values are a quick way to make two dimensions equal, but the shared value is harder to find later.

Can an assembly drive part dimensions with equations?

It can, but it creates an external reference from the part to the assembly. For parts reused in several products, keep the variables in the part, or link the parts to a shared external text file.