SOLIDWORKS’ Equations are a powerful way to create relationships in our designs that reflect our underlying intent. As a native Windows application, SOLIDWORKS lets us use common functions in our equations like those found in Excel or VBA. In fact, you are presented with a list of useful functions when creating a new equation:
Our focus is on the if() or IIF() function and its ability to invoke different parameter values, based on the value of a Global Variable. The basic syntax is IIF (expression , value_if_true, value_if_false).
The expression contains a Global Variable, and an arithmetic function evaluating the variable (equal to, greater than, less than, etc.). If this expression is found to be TRUE, then the value_if_true is returned. If the express is found to be FALSE, value_if_false is returned. Let’s look at this in play with a simple part.
In this handwheel model the Nominal Diameter can be varied, and we want to be sure the following design rules are honored as different size versions are investigated:
- If the Nominal Diameter of the handwheel is less than 185mm, there are three spokes. Otherwise, five spokes.
- If the Nominal Diameter is less than 185mm, the diameter of the hub is 25mm. Otherwise, 35mm.
- If the Nominal Diameter is less than 225mm, locate spoke bend 55mm from rim. Otherwise, 75mm.
Here are the equations reflecting the rules. Notice the Nominal Diameter of 170mm invoking value_if_true for the design parameters:
If we increase the Nominal Diameter to 230mm, all the equations are now in the FALSE state and the design parameters are set to value_if_false:
Rebuild your model and it will update to reflect the new parameters. Or if you turn on Instant3D, you can drag the dimension handle and see your model update in real time!