Alibre Design has an inbuilt capability to use equations in your designs. Similar capability is made available in

- Part Workspace (accessed via Equation Editor)
- Assembly Workspace (accessed via Equation Editor)
- Global Parameter Files

There are aspects of the way equations are handled which can be confusing. This article repeats information that can be found in the Help, and expands on it. For more complex use of equations (and sometimes to make things easier to follow), spreadsheet driven design may provide a better solution.

Equations in Alibre Design allow Parameters (values relating to your design) to be defined and to be related to each other using mathematical functions and operators.

Alibre Design recognises 4 types of Parameter, it is important to know which type should be used when. Incorrect mixing of types in an equation can lead to errors.

As we look at the 4 types of Parameters which are used, we'll mention both Units and Dimensions - these are related, but are not identical. Also note that Dimensions in this mathematical context are not the same thing as in a drawing or sketch.

Parameter Type | Units | Dimensions | Comments |

Distance | mm, cm, inch, feet | Length | |

Angle | degrees, radians | Dimensionless (see note) | |

Count | Dimensionless | Integer only (whole numbers) | |

Scale | Dimensionless | Real (can include fractional part) |

NOTE:Though angles are expressed with units, mathematically an angle is a ratio of distances, so is dimensionless.

Alibre Design is pedantic about Dimensionality in equations, if there is a mismatch the equation text will show RED. Note that trying to use an incompatible type for a parameter will also show RED equation text.

Because any Parameter that we create will have dimensions of Length, or be dimensionless, the results of any equations must also match this. So if we wish to set a Distance, the equation used MUST have dimensions of Length.

Distance2 = Distance11 * 1.5 is acceptable, as is Distance3 = Distance1 + Distance2 , or even Distance2 = Distance1 * Angle1

Distance3 = Distance2 * Distance1 is not acceptable, because dimensions are inconsistent (Length one side, Length squared on the other).

Units are another complication in equations. Alibre can Display in units chosen by the user, you can even change the display units part way through a design without the size altering. It won't surprise you to know that internally Alibre does not actually change units at all - it uses what we call 'model units'. For all **natively generated** designs the model units are **cm** for distance and **radians** for angle. Equations actually carry out any calculations using these model units - this can lead to some surprising results!

If D1 = 27.34mm, but we'd like to only work in whole mm, we might try D2 = INT(D1) but the result is not what we expect.

Inside Alibre Design 27.34mm is represented as 2.734cm, the INT(x) function removes the decimal part leaving 2cm. This becomes 20mm in display units. If we try something similar whilst working in inches the results are even more bizarre, but for the same underlying reason.

The result displayed for D2 is the inch equivalent of 13cm.

If you need to force Alibre Design to work correctly with your display units, you have to add some intermediate steps. And because the capabilities are a bit limited, it isn't possible to do everything in a single step (as you could in a spreadsheet).

Here the Parameter ONE has been given a value of 1 display unit (mm in this case). TEMP is a Scale value -- dimensionality is made correct by dividing D1 (Length) by ONE (Length), giving a dimensionless number. This value can then have the INT(x) function applied, with the result multiplied by ONE (Length) to get correct dimensions.

In truth this could be achieved a little more simply if TEMP had been defined as a Count (Integer) instead of Scale (Real) - there would be no need to use the INT(x) function.

If you try to combine the D1/ONE into the INT(x) function, missing out the TEMP value, Alibre Design can't handle that.

Let's look at angles - we might want to use trigonometry to work out one distance from another, for example

D2 = D1 * TAN(45°) - chosen to make this obvious because TAN(45°) = 1 , let's see what we get.

The issue here is that because 45 was typed into the equation editor it was assumed by Alibre Design to be 45 Radians ! If instead an angle parameter had been set (assuming display dimension for angle was set to degrees), or if 'deg' had been typed after 45 (to force degrees) directly into the TAN function. The result would be in line with our expectations.

The Equation Editor is a very useful and powerful tool, but unless care is taken it can give unexpected results. When first setting up equations, it is a good idea to input some values for which the result is already known - that way you can check for any unexpected results. It is essential that dimensionality is maintained correctly, it is also important to understand the difference between display units and model units to avoid problems.

The functions in the table below may be used within equations - if more complex functions are required, consider using a spreadsheet to drive the design.

Function | Name | Description | Example |

abs(x) | absolute value | Returns the absolute value of an argument, result always has positive sign. | abs(2) = 2 abs(-2) = 2 |

sign(x) | sign | Returns the sign of the argument. The argument can be any valid numeric expression. If the number is zero or positive, sign() returns 1, and if negative the sign() returns -1. | sign(-6) = -1 sign(0) = 1 sign(5) = 1 |

int(x) | integer | Returns the integer portion of the argument. The argument can be any valid numeric expression. The sign of the result will be the same as the sign of the argument. | int(1.234) = 1 |

frac(x) | fraction | Returns just the decimal portion of the argument. The sign of the result will be the same as the sign of the argument. | frac(1.234) = 0.234 |

sin(x) | sine | Returns the sine of an angle. The argument can be any valid numeric expression in radians. | SIN(PI/2) = 1 |

asin(x) | inverse sine | Returns an angle (in radians), which has sine value equal to the argument | |

cos(x) | cosine | Returns the cosine of an angle. The argument can be any valid numeric expression in radians. | COS(PI) = -1 |

acos(x) | inverse cosine | Returns an angle (in radians), which has cosine value equal to the argument | |

tan(x) | tangent | Returns the tangent of an angle. The argument can be any valid numeric expression that expresses an angle in radians. | TAN(PI/4) = 1 |

atan(x) | inverse tangent | Returns an angle (in radians), which has tangent value equal to the argument | |

sqrt(x) | square root | Returns the square root of the argument. x > 0 | sqrt(2) = 1.414 (but watch out for units) |

X^n | Xn | Raises X to the power n. Fractional values of n can be used to find roots (but only where X is positive). | 2^3 = 8 8^(1/3) = 2 |

% | Remainder | A%B returns the remainder part after dividing B into A | 15%9 = 6 , 10%15 = 10 |

PI | Pi | Approx 3.14159 |

IMPORTANT NOTE - If a design is based upon an imported file, the model units used by Alibre Design will be those defined by the imported file - not necessarily cm. You may therefore see different results to the same equation if applied to an imported file rather than a natively generated file. The earlier advice to test the behaviour of equations applies especially to files based upon imported geometry.

Parameter Naming - Take care not to use names that Alibre might mistake for units of measure. For example if you type m or M it will be assumed to indicate 1m, if you type mm or MM it will be assumed to indicate 1mm. This will lead to unexpected results if you name a parameter as MM (for example) and then use its name in an equation!