Expression System
Build formulas with arithmetic operators and functions like min, max, clamp, and step in Print CAD.
Print CAD's expression system lets you write formulas that compute values dynamically from variables and constants. Expressions can be used anywhere a numeric value is accepted — dimensional constraints, variable definitions, and rule formulas. This enables complex parametric relationships where one dimension depends on calculations involving multiple variables.
Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
+ | Addition | W + 0.5 |
- | Subtraction | L - A |
* | Multiplication | W * 2 |
/ | Division | D / 3 |
Expressions follow standard mathematical order of operations. Use parentheses to control evaluation order: (W + A) * 2.
Functions
Print CAD extends the base expression system with functions useful for packaging design:
| Function | Syntax | Description |
|---|---|---|
| min | min(a, b) | Returns the smaller of two values. Useful for constraining a dimension to never exceed a limit: min(W, 24) |
| max | max(a, b) | Returns the larger of two values. Useful for enforcing minimum sizes: max(D, 1) |
| clamp | clamp(value, min, max) | Restricts a value to a range. Equivalent to max(min, min(max, value)). Example: clamp(A, 0.25, 1.0) |
| step | step(value, threshold) | Returns 0 if value is below threshold, 1 if at or above. Useful for conditional geometry that appears only above a certain size. |
| sqrt | sqrt(x) | Square root. Useful for diagonal calculations: sqrt(WW + DD) |
| sin | sin(angle) | Sine of angle in degrees. |
| cos | cos(angle) | Cosine of angle in degrees. |
| asin | asin(value) | Arcsine, returns angle in degrees. |
| acos | acos(value) | Arccosine, returns angle in degrees. |
| pi | pi | The constant 3.14159... |
Expression Examples for Packaging
| Expression | Use Case |
|---|---|
W + A * 2 | Total width including allowance on both sides |
D / 2 + 0.125 | Half-depth tuck flap with 1/8" extra for overlap |
min(W, L) * 0.1 | Glue tab width proportional to the shorter dimension |
clamp(D * 0.5, 0.5, 2.0) | Flap depth that scales with box depth but stays between 0.5" and 2" |
step(W, 12) * 0.25 | Add 0.25" reinforcement only when width exceeds 12" |
sqrt(WW + DD) | Diagonal dimension for angled structural elements |
Expressions in Rules
The same expression syntax is used in Rules formulas and Auto Flute area formulas in the Custom Libraries admin. Variable names in expressions must match the parameter Variable names exactly (case-sensitive).
Related Pages
- Variables — Define the named values that expressions reference
- Constraints — Enter expressions directly into dimensional constraints
- Rules — Write restriction formulas using expression syntax
- Auto Flute — Use expressions in the area calculation formula