🌎 All English Articles  |  🇯🇵 Japanese Version

SolidWorks Equations and Global Variables: Design Faster with Parameters

SolidWorks Equations and Global Variables: Design Faster with Parameters English

The Problem with Manual Dimension Editing

Most engineers start by typing dimension values directly: 50 mm here, 25 mm there. The model works. Then the customer asks to change the width from 100 mm to 120 mm — and suddenly you are editing twelve dimensions manually, hoping you caught all of them, hoping none of the ratios were supposed to stay fixed.

SolidWorks Equations and Global Variables solve this. They let you define a set of master parameters and drive all model dimensions from those parameters. Change one value, rebuild, and the entire model updates correctly.

This is not a luxury feature. For any design with repeated geometry or predictable dimensional relationships, parametric equations save significant time and eliminate a class of manual editing errors.

Opening the Equations Dialog

Go to Tools > Equations (or right-click the Equations entry in the Feature Manager tree). The Equations dialog has three sections:

  • Global Variables: standalone named values, not linked to any specific dimension.
  • Features: equations that drive model dimensions directly.
  • Equation View / Dimension View / Ordered View: three display modes for the same data.

Use Global Variables for the master parameters — width, height, thickness, pitch — that other dimensions reference. Use feature equations to express relationships between dimensions.

Global Variables: The Foundation

A global variable is a named number. Example:

  • “Width” = 100
  • “Height” = 150
  • “Thickness” = 6
  • “BoltPitch” = 50

Add them in the Global Variables section of the Equations dialog. Names are case-sensitive and cannot contain spaces (use underscores: “Bolt_Pitch”).

Once defined, any dimension in the model can reference a global variable by typing its name preceded by a quote mark: "Width". The dimension evaluates to the variable’s current value. When you change the global variable, every dimension referencing it updates on rebuild.

Global variables also accept expressions: “Width” = “Height” * 0.75 defines a fixed aspect ratio. Change Height, and Width follows automatically.

Dimension-Driven Equations

Equations that drive dimensions use SolidWorks dimension names on the left side. The dimension name format is: D1@SketchName (for sketch dimensions) or D1@FeatureName (for feature dimensions).

Example: a mounting hole is always centered on the part width. In the sketch for the hole, the horizontal position dimension (D1@Sketch2) should equal half the width:

"D1@Sketch2" = "Width" / 2

Now the hole stays centered regardless of how Width changes. The dimension becomes driven (shown in gray in the sketch) — you cannot manually edit it anymore, which is correct behavior for a constrained parameter.

Linked Values: Connecting Multiple Dimensions

You can link multiple dimensions to the same value without using a global variable. Right-click any dimension, select Link Values, and assign a name. Any other dimension linked to the same name updates together.

This is useful for equal-length relationships that are specific to one part and do not need to be accessible from the top-level equations dialog. For relationships that need to be visible and modifiable at the part level, use global variables instead — they are easier to find and manage.

If/Then Logic

SolidWorks equations support conditional logic using the IIF function:

IIF(condition, value_if_true, value_if_false)

Example: a gusset thickness that is 2×material thickness for widths over 200 mm, but 1.5×material thickness for smaller widths:

"Gusset_T" = IIF("Width" > 200, "Thickness" * 2, "Thickness" * 1.5)

Conditional equations let you build “design rules” into the model — geometry that automatically adapts to size changes without manual judgment calls. Use this with care: complex conditional logic in equations can make models difficult for others to understand and debug.

Mathematical Functions Available

SolidWorks equations support standard mathematical operations and functions:

  • Arithmetic: +, -, *, /
  • Exponentiation: ^ (e.g., “Width”^2)
  • Square root: sqr(“Area”)
  • Trigonometric: sin(), cos(), tan() — angles in degrees by default
  • Rounding: int() truncates to integer, round() rounds to nearest integer
  • Absolute value: abs()

These are sufficient for most mechanical design calculations. For anything more complex — iterative solutions, optimization — use a linked Excel spreadsheet instead.

Linking to Excel

For designs driven by a large parameter set, SolidWorks can link global variables to an Excel spreadsheet through Design Tables. Right-click the Configurations entry in the Feature Manager tree and select Insert > Design Table > From File.

Each column in the spreadsheet corresponds to a configuration parameter. Each row is a design configuration. This is the right approach for a family of parts (e.g., brackets in 10 sizes) rather than a single design with equations.

Practical Example: Parametric Mounting Bracket

Design requirement: a mounting bracket with a configurable width (W), height (H), material thickness (T), and two bolt holes spaced at W/3 from each edge.

Global variables defined:

  • “W” = 120 (mm)
  • “H” = 80 (mm)
  • “T” = 3 (mm)

Sketch equations:

  • Base rectangle width: "D1@Sketch1" = "W"
  • Base rectangle height: "D2@Sketch1" = "H"
  • Left hole X position: "D1@Sketch2" = "W" / 3
  • Right hole X position: "D2@Sketch2" = "W" * 2 / 3
  • Both holes Y position: "D3@Sketch2" = "H" / 2

Base Flange thickness equation:

  • "Thickness@BaseFlange1" = "T"

Now change W from 120 to 180 mm in the Equations dialog, rebuild, and the bracket grows correctly. Both holes move to maintain their relative positions. The flange thickness is controlled by T. No manual editing of individual dimensions required.

Best Practices

Name variables clearly

Use descriptive names: “Flange_Width” not “FW”. Someone reading the model six months later should understand what every variable means without opening the equations dialog.

Document units

SolidWorks equations work in the document units. If you switch unit systems, check all equations. Add comments (preceded by ‘) to equations that have non-obvious values: 'Material thickness in mm, per DIN EN 10130

Keep equations simple

Deeply nested IIF logic and complex chained expressions are hard to debug. If an equation is getting complex, split it into intermediate global variables and build up the final result step by step.

Test before releasing

After adding equations, test the model by changing each global variable through its expected range. Verify that the model rebuilds without errors and the geometry changes as expected. Equations that work at the nominal value often break at extreme values.

Key Takeaways

  • Global variables are named master parameters — define your key dimensions there and reference them everywhere in the model.
  • Dimension-driven equations express relationships: a hole that is always centered, a wall that is always a fixed ratio of the overall width.
  • IIF conditional logic lets you build design rules into the model — but keep it readable.
  • For a family of parts, use Design Tables linked to Excel instead of equations.
  • Test parametric models through their full range — equations that work at nominal often break at extremes.

コメント

タイトルとURLをコピーしました