# Numeric Fields

When entering values and parameter expressions in numeric fields throughout Onshape, you are able to use the keyboard and also the mouse scroll wheel:

Scroll+Key | Result |
---|---|

scroll wheel default | increments of 0.1 |

Ctrl-scroll wheel | increments of 0.01 |

Shift-scroll wheel | increments of 1.0 |

Numeric value fields throughout Onshape Part Studios and Assemblies accept integers, decimals, parameter expressions and trigonometric functions. Default units dictate the unit when no other unit is entered in the numeric field, but you can always enter any unit. Onshape will convert and display the value in default units. When you click in the field, however, the original units are displayed again.

Keyword type | Keywords accepted | Examples |
---|---|---|

Length |
mm, millimeter, cm, centimeter, m, meter, in, inch, ft, foot, yd, yard |
5mm |

Angle units |
deg, degree, rad, radian |
7deg (or 7 degree) 14rad (or 14 radian) |

Math functions |
+, -, *, /, ^, ceil, floor, round, exp, sqrt, abs, max, min, log, log10 |
2^3 |

Modulo operator |
% |
5%2 (returns 1) |

Trigonometric functions |
cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, asinh, acosh, atanh |
These functions are in degrees, not radians. For example: sin(30) = sin(30 deg) = .5 atan2(4, 5) (Give the polar angle of (5,4) in as an angle) |

Constants |
pi, PI, Pi |
(3*pi) in |

Parameter expressions are evaluated as FeatureScript.

- Parameter expressions are available in Part Studios and Assemblies.
- Parameter expressions must either result in a unit-less value, or result in a unit value to the first power.
- After a numeric field has been accepted, the evaluation of the expression is displayed. When the field is active again, the original expression is displayed.
- Use any units (if the field accepts units), but don't mix types (such as degrees and millimeters):
**Valid****Invalid**3in + 2.5in

3 + 2.5in

3mm + 2.5in

3mm + 2deg

3 + 2

3in + 2 (2*3)*(1/3)

(2*3)(1/3)

sqrt(16)m

sqrt(16m)

cos(30deg)

30

^{o}

- Plurals of all length and angle units are allowed (for example: feet, radians, etc.).
- Most parameters are lengths or angles. Some parameters are unit-less, like Rho and pattern instance counts.
- Fractions are supported.
- Use parentheses when necessary. For example, (2*3)*(1/3).

Global variables and equations are not yet supported. Local variables are supported in Part Studios.

For unit-less expressions, all unit-less expressions are accepted and follow the standard order of evaluation. For example: 3+(2*3)/6

For single-unit expressions, all single units are accepted if the expression ends with a unit to the first power. For example: 3mm + (2mm*3mm)/(6mm), and 3mm + 2mm

For multiple-unit expressions, all multiple-unit expressions are accepted if the result is a unit to the first power. For example: 3[unit] + 3[unit] is accepted, but 3[unit] * 3[unit] is not accepted.

When creating custom features using FeatureScript, you are able to use trigonometric functions in numeric fields. Keep the following in mind:

Unit-less parameters are accepted. For example: sin(30) and sin(asin(1)).

Inverse trigonometric functions are accepted. For example: atan(1), atan(1)/deg. Be aware that asin/acos/atan return a degree, so you need to divide by degree to get a unit-less value.

For more information on FeatureScript, see Welcome to FeatureScript (opens in new tab) and for more information on creating custom features, see Add Custom Features.

Onshape supports array/lookup tables such as this:

**[3,5,6,7][2]** with:

**[3,5,6,7]**being the array**[2]**being the position**6**being the second value in the array

Remember the array starts at position 0.

Another example is: **[3,5,6,7][3]=7**

You are also able to use ternary operators (such as '?') which may yield conditional results. For example, say the length of a sketch entity should be 7 inches if the width is greater than 5 inches. It can be written this way:

**#width>5?7:4**

Where:

**#width>5**is the conditional statement**?**is the ternary operator**7**being if the expression is true (if the width is greater than 5), make the length 7 inches**4**being if the expression is false (if the width is 5 or less), make the length 4 inches

- 3in*3in
- 3 + 3in (Because unit-less + unit does not compute.)
- 3[unit]*3[unit] (This results in [unit]^2, which is not accepted.)
- sin(30)/deg (This results in a 1/deg unit, which is not accepted.)
- Anything resulting in 1/[unit] is not accepted.
- A unit over a unit if there is a separate unit, for example: 3[unit]+1[unit]/2[unit].

- Inverse trigonometric functions take numeric values and return angles; for example: atan(1) = 45 degrees.
- To use a unit-less value (perhaps to enter into a dimension field), divide by the default angle unit; for example: [atan(1)/deg].
- Plurals of all length and angle units are allowed (for example: feet, radians, etc.).

- Use parentheses when necessary. For example, (2*3)*(1/3).

- Fractions are supported.
- Most parameters are lengths or angles. Some parameters are unit-less, like Rho and pattern instance counts.

Global variables and equations are not yet supported. Local variables are supported in Part Studios.

Numeric value fields throughout Onshape Part Studios accept integers, decimals, expressions and trigonometric functions. Default units dictate the unit when no other unit is entered in the numeric field, but you can always enter any unit. Onshape converts and displays the value in default units. When you tap in the field, however, the original units are displayed again.

Expressions are entered into numeric fields using the Mobile Number Pad's keyboard option (see Numeric Fields). Currently, expressions can be used only in Part Studios.

Keyword type | Keywords accepted | Examples |
---|---|---|

Length |
mm, millimeter, cm, centimeter, m, meter, in, inch, ft, foot, yd, yard |
5mm |

Angle units |
deg, degree, rad, radian |
7deg (or 7 degree) 14rad (or 14 radian) |

Math functions |
+, -, *, /, ^, ceil, floor, round, exp, sqrt, abs, max, min, log, log10 |
2^3 abs(-4) max(2, 3) (sqrt(2in * 3mm)) and sqrt(4 in^2) exp(2) |

Modulo operator |
% |
5%2 (returns 1) |

Trigonometric functions |
cos, sin, tan, acos, asin, atan, atan2, cosh, sinh, tanh, asinh, acosh, atanh |
These functions are in degrees, not radians. For example: sin(30) = sin(30 deg) = .5 atan2(4, 5) (Give the polar angle of (5,4) in as an angle) |

Constants |
pi, PI, Pi |
(3*pi) in |

Onshape supports array/lookup tables such as this:

**[3,5,6,7][2]=6** with:

**[3,5,6,7]**being the array**[2]**being the position within the array**6**being the value

Remember the array starts at position 0.

Another example is: **[3,5,6,7][3]=7**

You can also use ternary operators (such as '?') which can yield conditional results. For example, say the length of a sketch entity should be 7 inches if the width is greater than 5 inches. It can be written this way:

**#width>5?7:4**

Where:

**#width>5**is the conditional statement**?**is the ternary operator**7**being if the expression is true (if the width is greater than 5), make the length 7 inches**4**being if the expression is false (if the width is 5 or less), make the length 4 inches

- With the number pad open, tap the keyboard button.

The number pad minimizes and a keyboard appears.

- Enter an expression with the keyboard.
- Tap the check to accept the expression or the x to cancel.

- Expressions are available in Part Studios and Assemblies.
- Expressions must either result in a unit-less value, or result in a unit value to the 1st power.
- After a numeric field has been accepted, the evaluation of the expression is displayed. When the field is active again, the original expression is displayed.
- Use any units (if the field accepts units), but don't mix types (such as degrees and millimeters):
**Valid****Invalid**3in + 2.5in

3 + 2.5in

3mm + 2.5in

3mm + 2deg

3 + 2

(2*3)(1/3)

(2*3)*(1/3)

sqrt(16m)

sqrt(16)m

30

^{o}cos(30deg)

- Plurals of all length and angle units are allowed (for example: feet, radians, etc.).
- Most parameters are lengths or angles. Some parameters are unit-less, like Rho and pattern instance counts.
- Fractions are supported.
- Use parentheses when necessary. For example, (2*3)*(1/3).

Global variables and equations are not yet supported. Local variables are supported in Part Studios.

For unit-less expressions, all unit-less expressions are accepted and follow the standard order of evaluation. For example: 3+(2*3)/6

For single-unit expressions, all single units are accepted if the expression ends with a unit to the first degree. For example: 3mm + (2mm*3mm)/(6mm), and 3mm + 2mm

For multiple-unit expressions, all multiple-unit expressions are accepted if the result is a unit to the first degree. For example: 3[unit] + 3[unit] is accepted, but 3[unit] * 3[unit] is not accepted.

You can use trigonometric functions in numeric fields. Keep the following in mind:

Unit-less parameters are accepted. For example: sin(30) and sin(asin(1)).

Inverse trigonometric functions are accepted. For example: atan(1), atan(1)/deg. Be aware that asin/acos/atan return a degree, so you need to divide by degree to get a unit-less value.

- 3in*3in
- 3 + 3in (Because unit-less + unit does not compute.)
- 3[unit]*3[unit] (This results in [unit]^2, which is not accepted.)
- sin(30)/deg (This results in a 1/deg unit, which is not accepted.)
- Anything resulting in 1/[unit] is not accepted.
- A unit over a unit if there is a separate unit, for example: 3[unit]+1[unit]/2[unit].

- Inverse trigonometric functions take numeric values and return angles; for example: atan(1) = 45 degrees.
- To use a unit-less value (perhaps to enter into a dimension field), divide by the default angle unit; for example: [atan(1)/deg].
- Plurals of all length and angle units are allowed (for example: feet, radians, etc.).

- Use parentheses when necessary. For example, (2*3)*(1/3).

- Fractions are supported.

Global variables and equations are not yet supported. Local variables are supported in Part Studios.