Examples of expressions

 

 

 

 

ceil, round and floor functions allow you to get the rounded-off value and to choose unit. These 3 functions work the same way.

 

The function uses 2 informations, The first one is the one you want to get the rounded-off value The second one is a string containing the step for the rounding-off and its reference unit (e.g.:2mm for a step of two in millimeters).

 

 

The result is given in the current unit of TopSolid.

 

 

 

 

Let a parameter be a = 125.36 cm with the cm as current unit in TopSolid.

  • round(a;1mm) = 125.4cm

  • round(a;1dm) = 130 cm

The step for the rounding off can be modify. So we get:

  • round(a;10cm) = 130 cm

  • floor(a;10cm) = 120 cm

  • round(a;2mm) = 12.6 cm

  • round(a;2cm) = 12 cm

 

when:

 

The when function allows to add conditions between parameters.

when (A>B;C;D) means: if A > B the result is C and D otherwise.

 

 

 

If c > 5mm then l=150mm, l=100mm otherwise

  • Create the parameter c=10mm

  • Create the parameter l=when(c>5mm;150mm;100mm). The result l=150mm.

If c < 5mm then l = 11.5 mm

if 5mm <= c < 10 mm then l = 13mm

if c >= 10 mm then l = 15mm

  • Create the parameter c = 10mm

  • Create the parameter l = when(c>=5mm;when(c>=10mm;15mm;13mm);11.5mm)

 

 

When you want to make a double test like for example c > 5mm and c <= 100, you cannot type: when (5mm < c <= 10mm;...) because TopSolid will compute the first part of the expression (5mm < c) and replace it by the result (0 or 1) in the second part of the expression, so it will always return 1 in our example.

In such case, you have to use the AND logical operator and type: when ( c > 5mm && c <= 10mm;...)

 

 

val:

 

The val function allows to convert a string of character made of numbers into a real or an interger value.

 

 

 

T is a text parameter and T = "2018", you can get its value into a real parameter of factor type with R = val(T)

The decimal separator can be used in the text parameter: if T = "2018.45" then R = val(T) = 2018.45

You must pay attention to the units, if T = "2018.45" and if R is a real parameter of Length type, you'll have to type R = 1mm*val(T) in order to get R = 2018.45mm

 

T is a text parameter and T = "2018", you can get its value into an integer parameter with I = val(T)

If the text contains a decimal separator, the numerical value located before this separator will be retrieved only: if T = "2018.45" then I = val(T) = 2018