Functions in variable formulas
You can use functions to calculate values for parametric variables. Variable formulas always begin with the equal sign (=).
For more information, see Use parametric variables to set object properties.
Arithmetic operators
Use arithmetic operators to combine expressions that return numeric values.
|
Operator |
Description |
Notes |
|---|---|---|
|
+ |
addition |
Use also to create strings of parameters. |
|
- |
subtraction |
|
|
* |
multiplication |
Multiplication is faster than division.
|
|
/ |
division |
Logical and comparison operators
Use logical and comparison operators inside if statements. You can use if-then-else statements to test a condition and to set the value according to the result.
For example:
=if (D1>200) then 20 else
10 endif
You can use the following operators inside if statements:
|
Operator |
Description |
Example |
|---|---|---|
|
== |
both sides are equal |
|
|
!= |
sides are not equal |
|
|
< |
left side is smaller |
|
|
<= |
left side is smaller or equal |
|
|
> |
right side is smaller |
|
|
>= |
right side is smaller or equal |
|
|
&& |
logical AND both conditions must be true |
If D1 is 200 and D2 smaller than 40, the result is 6, otherwise 0. |
|
|| |
logical OR only one condition must be true |
If D1 is 200 or D2 is smaller than 40, the result is 6, otherwise 0. |
Reference functions
Use reference functions to refer to the property of another object, such as the plate thickness of a secondary part. Tekla Structures refers to the object on the system level, so if the object property changes, so does the reference function value.
|
Function |
Description |
Example |
|---|---|---|
|
|
Returns the template attribute value of an object that has a given object GUID. |
returns the weight of an object whose GUID is ID50B8559A-0000-010B-3133-353432373038. |
|
|
Returns the user-defined attribute value of an object that has a given object GUID. |
returns the user-defined attribute comment of an object whose GUID is ID50B8559A-0000-010B-3133-353432373038. |
|
|
Returns the value of the parameter. |
If the equation
is With |
|
|
Returns the reinforcing bar catalog value of an object.
|
returns the size, usage, and weight of an object whose reinforcing bar grade is A500HW. |
ASCII file as a reference function
You can refer to ASCII files to get data. Tekla Structures searches for the files in the following order:
-
model folder
-
..<model folder>\CustomComponentDialogFiles
-
project folder (
XS_PROJECT) -
firm folder (
XS_FIRM) -
system folder (
XS_SYSTEM) -
profile database folder (
XS_PROFDB) -
<model folder>\cr (cold rolled components)
The parameters used are: file name, key value of row, column number, separator(s), allow empty columns. The format for reading the files is as follows:
fVF("filename",
"key_value_of_row", column_number, "separator(s)", FALSE)
- Key value of a row: A unique key value string that is used to select the line in the file. The search is case-sensitive. The string must not contain spaces, tabs, or any of the specified separator characters.
- Column number: An index starting from 1 to select the value from the chosen line. Index 1 corresponds to the key value.
-
Separators: Optional parameter. The separator consists of one or more characters used for data separation. The default separators are space and tab.
The specified character sequence will be interpreted as a set of characters, each treated as an individual separator, not as a group. Use "\t" to represent a tab. For example, " \t" means that space and tab will be treated as separators, and ",.;" means that comma, dot, and semicolon will be treated as separators.
-
Allowing empty columns: Optional parameter. The default for allowing empty columns is
FALSE.If it is set to
TRUE, empty entries from the file line will be considered when the function is resolved. If it is missing or set toFALSE, empty entries are removed.
Example
The
=fVF("Overlap.dat", "MET-202Z25", 5) function is in the
Formula box in the
Variables dialog. The function gets the value
16.0 for the profile
MET-202Z25, from the
Overlap.dat file.

- Key value of the row (MET-202Z25)
- Column number (5)
For more information, see the How to read data from a text file in Custom Components support article.
Mathematical functions
Use mathematical functions to create more complex mathematical expressions.
|
Function |
Description |
Example |
|---|---|---|
|
fabs(parameter) |
Returns the absolute value of the parameter |
if D1 = -15 |
|
exp(power) |
Returns e raised to the power e is Euler’s number. |
if D1 = 2 |
|
ln(parameter) |
Returns the natural logarithm of the parameter (base number e) |
if P2 = 15 |
|
log(parameter) |
Returns the logarithm of the parameter (base number 10) |
if D1=100 |
|
sqrt(parameter) |
Returns the square root of the parameter |
if D1 = 16 |
|
mod(dividend, divider) |
Returns the modulo of the division |
if D1 = 16 |
|
pow(base number, power) |
Returns the base number raised to the specified power |
if D1 = 3 and D2 = 2 |
|
hypot(side1,side2) |
Returns the hypotenuse
(1): side1 (2): hypotenuse (3): side2 |
if D1 = 3 and D2 = 4 |
|
n!(parameter) |
Returns the factorial of the parameter |
if P2 = 4 (1*2*3*4) |
|
round(parameter, accuracy) |
Returns the parameter rounded off to the given accuracy |
if P1 = 10.567 |
|
PI |
Returns the value of pi to 31 decimal places |
|
Statistical functions
Use statistical functions to calculate sums and averages, and to round values.
|
Function |
Description |
Example (P1 = 1.4 P2 = 2.3) |
|---|---|---|
|
ceil() |
Returns the smallest whole number greater than or equal to the parameter |
|
|
floor() |
Returns the largest whole number less than or equal to the parameter |
|
|
min() |
Returns the smallest parameter |
|
|
max() |
Returns the largest parameter |
|
|
sum() |
Sum of the parameters |
|
|
sqsum() |
Sum of the squared parameters: (parameter1)2 + (parameter2)2 |
|
|
ave() |
Average of the parameters |
|
|
sqave() |
Average of the squared parameters |
|
Example: Ceil and floor statistical functions
In this example, you have the following parametric variables:
- Beam length: P1 = 3500
- Post spacing: P2 = 450
P1 / P2 = 7.7778
You can use the
ceil and
floor statistical functions to round the value and then use the rounded value as the number of beam posts:
=ceil(P1/P2)returns 8=floor(P1/P2)returns 7
Data type conversion functions
Use data type conversion functions to convert values into another data type. Conversion functions perform conversions between the three supported data types: integers, doubles, and strings.
|
Function |
Description |
Example |
|---|---|---|
|
int() |
Converts data to integer |
Useful especially for calculating profile dimensions:
|
|
double() |
Converts data to a double |
|
|
string() |
Converts data to string |
|
|
imp() |
Converts imperial units Use this function in calculations instead of imperial units. You cannot use imperial units directly in calculations. |
For the following examples, length unit is set to mm and decimals are set to 2 in the Options dialog.
|
|
vwu(value, unit) |
Converts the length values and angle values. The available units are:
|
Note that Tekla Structures automatically converts
angles from degrees to radians by multiplying by To ensure that the angles are correctly calculated, use
|
The units depend on the settings in .
String operations
Use string operations to manipulate character strings. Strings must be inside quotation marks in variable formulas.
|
Operation |
Description |
Example (P1 = "PL100*10") |
|---|---|---|
|
match(parameter1, parameter2) |
Returns 1 if parameters are equal and 0 if different. You can also use
wildcards |
Accept all profiles starting with PFC:
Accept profiles
starting with PFC, and height starts with 2, 3, 4 or 5:
Accept profiles
starting with PFC, heights are 200, 300, 400 or 500 and
width starts with 7: |
|
length(parameter) |
Returns the number of characters in the parameter. |
|
|
find(parameter, string) |
Returns the order number (starting at zero) of the specified string and -1 if the specified string is not found from the parameter. |
|
|
getat(parameter, n) |
Returns the n:th (starting at zero) character from the parameter. |
|
|
setat(parameter, n, character) |
Sets the n:th (starting at zero) character to the specified character in the parameter. |
|
|
mid(string, n, x) |
Returns x characters from the string starting from n:th (starting at zero) character. If you leave out the last argument (x), returns the last part of the string. |
|
|
reverse(string) |
Reverses the given string. |
|
Example 1
To define profile size PL100*10 with two variables P2 = 100 and P3 = 10, enter the formula as follows:
="PL"+P2+"*"+P3
Example 2
Tekla Structures handles bolt spacings as strings. To define bolt spacing, set Value type to Distance list and enter the formula as follows:
=P1+" "+P2
This results in 100 200, if P1 = 100 (length) and P2 = 200 (length).
Trigonometric functions
Use trigonometric functions to calculate angles.
When you use trigonometric functions in variable formulas, you need to include a prefix to define the unit. If you do not include a prefix, Tekla Structures uses radians as the default unit.
- d is degree. For example,
sin(d180) - r is radians (default). For example,
sin(r3.14)orsin(3.14)
|
Function |
Description |
Example |
|---|---|---|
|
sin() |
Returns the sine value |
|
|
cos() |
Returns the cosine value |
|
|
tan() |
Returns the tangent value |
|
|
asin() |
Inverse function of sin(), return value in radians |
|
|
acos() |
Inverse function of cos(), return value in radians |
|
|
atan() |
Inverse function of tan(), return value in radians |
|
|
sinh() |
Returns the hyperbolical sine value |
|
|
cosh() |
Returns the hyperbolical cosine value |
|
|
tanh() |
Returns the hyperbolical tangent value |
|
|
atan2() |
Returns the angle whose tangent is the quotient of the two numbers. Return value in radians |
|
Market size function
Use the market size function in a custom component to select a suitable plate dimension (usually plate thickness) from the available market sizes. For example, a plate’s thickness should match the web of a beam.
|
Function |
Description |
Example |
|---|---|---|
|
fMarketSize(material, thickness, extrastep) |
Returns the next available market size for the material from the marketsize.dat file, based on the thickness you specify. The file must be in the ..\environments\your_environment\profil folder or the system folder. For an extra step, enter a number to define the increment to the next size (default is 0). |
|
Example
In this example, you have the following data in marketsize.dat:
S235JR,6,9,12,16,19,22
SS400,1.6,2.3,3.2,4.5,6,9,12,16,19,22,25,28,32,38
DEFAULT,6,9,12,16,19,22,25,28,32,38
The first item in a row is a material grade followed by available plate thicknesses in millimeters. The DEFAULT line lists the thicknesses available in all other material grades.
With the above data, the function
=fMarketSize("S235JR",10,0) would return 12, and
=fMarketSize("S235JR",10,1) would return 16 (one size up).
Framing condition functions
Use the framing condition functions to return the skew, slope, and cant angle of the secondary beam relative to the main part (column or beam).
|
Function |
Description |
Example |
|---|---|---|
|
fAD("skew", GUID) |
Returns the skewed angle of the secondary part whose GUID is given.
|
ID50B8559A-0000-010B-3133-353432373038 is the GUID of the secondary part, which is at a 45 degree angle to the main part. |
|
fAD("slope", GUID) |
Returns the sloped angle of the secondary part whose GUID is given.
|
|
|
fAD("cant", GUID) |
Returns the cant angle of rotated secondary part whose GUID is given.
|
|
-
These functions do not return positive and negative slope and skew values. It is not possible to determine up or down slope and left or right skew with these functions.
-
The maximum skew angle to return is 45 degrees.
-
Tekla Structures calculates the angles in 2D so that slope and skew are isolated from each other. For example, the skew angle is not taken into consideration when calculating the slope angle, which means that the slope angle value stays the same regardless of the secondary part's rotation around the primary part.
To find out the true 3D slope with the skew included, you can use the following mathematical formula:
TRUE_SLOPE = atan( tan(SLOPE) * cos(SKEW))
Example 1
The slope and skew are relative to a beam framing into a column.
| Beam to column side view | Beam to column top view |
|---|---|
|
|
![]() |
- Column
- Beam
- Slope
- Skew
Example 2
With two beams, the slope is actually the horizontal skew of the beam framing into the other beam, and the vertical slope of the beam relative to the main is actually the skew angle.
| Beam to beam side view | Beam to beam top view |
|---|---|
|
|
|
- Skew
- Slope





