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 Set object properties by using parametric variables.
Arithmetic operators
Use arithmetic operators to combine expressions that return numeric values. You can use the following arithmetic operators:
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 ifthenelse 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.
You can use the following reference functions:
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 ID50B8559A0000010B3133353432373038. 

Returns the userdefined attribute value of an object that has a given object GUID. 
returns the userdefined attribute comment of an object whose GUID is ID50B8559A0000010B3133353432373038. 

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

..\TeklaStructuresModels\<model>\CustomComponentDialogFiles\

project (set with advanced option
XS_PROJECT
) 
firm (set with advanced option
XS_FIRM
) 
system (set with advanced option
XS_SYSTEM
)
The format for reading files is the following:
fVF("filename",
"key_value_of_row", column_number)

Key value of row is a unique text value.

Column number is an index starting from 1.
You can specify a character for data separation: fVF(data file, lookup value,
column#[, separator character])
.

You can use a preferred column separator of choice. This enables the support for spaces in names, profiles, shapes, and so on, as well as the use of distance lists as input.

You can use blank or empty strings as input.

Only a single character can be used as a separator. For example, you cannot use a more complex separator such as
"/+/"
, because only the first character would be considered as a column separator.
Example
The
=fVF("Overlap.dat", "MET202Z25", 5)
function is in the
Formula box in the
Variables dialog box. The function gets the value
16.0
for the profile
MET202Z25
, from the
Overlap.dat file.

Key value of the row (MET202Z25)

Column number (5)
Mathematical functions
Use mathematical functions to create more complex mathematical expressions. You can use the following functions:
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

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. You can use the following statistical functions:
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. You can use the following data type conversion functions:
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 box.

vwu(value, unit) 
Converts the length values and angle values. The available units are:


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.
You can use the following string operations:
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. 

replace(source string, old substring, new substring) 
Replaces all specified substrings with another 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. You can use the following trigonometric functions:
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 

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)
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). You can use the following framing condition functions:
Function 
Description 
Example 

fAD("skew", GUID) 
Returns the skewed angle of the secondary part whose GUID is given.

ID50B8559A0000010B3133353432373038 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.
Side view 
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.
Side view 
Top view 


 Skew
 Slope