Using metric units-agnostic resizable structures with the unitconv function (Example)

Problem

When you design a resizable structure — a component or a resizable template — you normally parameterize it using your current metric units. But if the structure is later used in projects that work with metric units other than your own, problems may occur with the mixing of measurement metric units. For example, you work in inches, but the structures you want to use are parameterized in millimeters. Using different metric units in your project may well lead to confusion in calculations.

To overcome this situation and design structures that work regardless of which metric system the user is working wсith, you can use the unitconv function. The function changes the way the program displays metric units without changing the actual lengths, angles or other parameterized values.

How the function works

The measurement units converting function unitconv presents the values set in one metric system into the units of another metric system. The function makes sure that values remain the same but are presented in the metric units the user wants to work with. The formula is especially handy when a structure was parameterized in one metric system (for example, mm) and is later used in a project that uses another metric system (for example, inches). For example, if in a structure a length is parameterized as 25 mm, when the structure is used in a project that works in inches, the length will stay the same but will be presented as 13/64 (in the Value column in the tabular area).

Syntax

The unitconv function has the following syntax.

unitconv(Arg 1; "Arg 2"; "Arg 3")

The function has three arguments: Arg 1 (value), Arg 2 (original units), and Arg 3 (converted units), where:

Arg 1 is a value.

Arg 2 is the measurement units for the Arg 1 value — mm, cm, dm, m, inch, foot, point, microns — when the value was first set.

Arg 3 is the measurement units into which the value will be displayed — current, mm, cm, dm, m, inch, foot, point, microns. NOTE: current converts the Arg 1 value into the currently used metric units.

Example

Normally, in the program the function is attached to the expression of a parameter and is most often used in the following pattern:

unitconv(25,00; "mm"; "current").

How to read the formula. Two cases

The program treats the parameter's value (Arg 1=25) in the metric units set in the second argument (Arg 2=mm). Consider these two cases:

See an example of how to use the unit conversion function in the expressions of perfa font parameters (Step 2).