Functions in variable formulas

Tekla Structures
2021
Tekla Structures

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.

=D1*0.5 is faster than =D1/2

/

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==200 && D2<40) then 6 else 0 endif

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==200 || D2<40) then 6 else 0 endif

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

fTpl("template attribute", "object GUID")

Returns the template attribute value of an object that has a given object GUID.

=fTpl("WEIGHT","ID50B8559A-0000-010B-3133-353432373038")

returns the weight of an object whose GUID is ID50B8559A-0000-010B-3133-353432373038.

fP("user-defined attribute", "object GUID")

Returns the user-defined attribute value of an object that has a given object GUID.

=fP("comment", "ID50B8559A-0000-010B-3133-353432373038")

returns the user-defined attribute comment of an object whose GUID is ID50B8559A-0000-010B-3133-353432373038.

fValueOf("parameter")

Returns the value of the parameter.

If the equation is =P2+"*"+P3, the result is P2*P3

With =fValueOf("P2")+"*"+fValueOf("P3"), where P2=780 and P3=480, the result is 780*480

fRebarCatalogValue(BarGrade, BarSize, Usage, FieldName)

Returns the reinforcing bar catalog value of an object.

Usage can be either 2 ("Tie") or 1 ("Main").

FieldName must be one of the following:

  • 0 NominalDiameter
  • 1 ActualDiameter
  • 2 Weight
  • 3 MinRadius
  • 4 Hook1Radius
  • 5 Hook1Angle
  • 6 Hook1Length
  • 7 HookRadius
  • 8 Hook2Angle
  • 9 Hook2Length
  • 10 Hook3Radius
  • 11 Hook3Angl
  • 12 Hook3Length
  • 13 Area

fRebarCatalogValue("A500HW", "10", 1, 2)

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:

  1. model

  2. ..\TeklaStructuresModels\<model>\CustomComponentDialogFiles\

  3. project (set with advanced option XS_PROJECT)

  4. firm (set with advanced option XS_FIRM)

  5. 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", "MET-202Z25", 5) function is in the Formula box in the Variables dialog box. The function gets the value 16.0 for the profile MET-202Z25, from the Overlap.dat file.

  1. Key value of the row (MET-202Z25)

  2. 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

=fabs(D1) returns 15

if D1 = -15

exp(power)

Returns e raised to the power

e is Euler’s number.

=exp(D1) returns 7.39

if D1 = 2

ln(parameter)

Returns the natural logarithm of the parameter (base number e)

=ln(P2) returns 2.71

if P2 = 15

log(parameter)

Returns the logarithm of the parameter (base number 10)

=log(D1) returns 2

if D1=100

sqrt(parameter)

Returns the square root of the parameter

=sqrt(D1) returns 4

if D1 = 16

mod(dividend, divider)

Returns the modulo of the division

=mod(D1, 5) returns 1

if D1 = 16

pow(base number, power)

Returns the base number raised to the specified power

=pow(D1, D2) returns 9

if D1 = 3 and D2 = 2

hypot(side1,side2)

Returns the hypotenuse

  1. side1

  2. hypotenuse

  3. side2

=hypot(D1, D2) returns 5

if D1 = 3 and D2 = 4

n!(parameter)

Returns the factorial of the parameter

=n!(P2) returns 24

if P2 = 4

(1*2*3*4)

round(parameter, accuracy)

Returns the parameter rounded off to the given accuracy

=round(P1, 0.1) returns 10.600

if P1 = 10.567

PI

Returns the value of pi to 31 decimal places

=PI returns 3.1415926535897932384626433832795

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

=ceil(P1) returns 2

floor()

Returns the largest whole number less than or equal to the parameter

=floor(P1) returns 1

min()

Returns the smallest parameter

=min(P1, P2) returns 1.4

max()

Returns the largest parameter

=max(P1, P2) returns 2.3

sum()

Sum of the parameters

=sum(P1, P2) returns 3.7

sqsum()

Sum of the squared parameters: (parameter1)2 + (parameter2)2

=sqsum(P1, P2) returns 7.25

ave()

Average of the parameters

=ave(P1, P2) returns 1.85

sqave()

Average of the squared parameters

=sqave(P1, P2) returns 3.625

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:

=int(100.0132222000) returns 100, if decimals are set to 0 in the Options dialog box

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.

=imp(1,1,1,2) meaning 1 foot 1 1/2 inch returns 342.90 mm

=imp(1,1,2) meaning 1 1/2 inches returns 38.10 mm

=imp(1,2) meaning 1/2 inches returns 12.70 mm

=imp(1) meaning 1 inch returns 25.40 mm

=3’/3" is not possible, but =imp(36)/imp(3) is ok

vwu(value, unit)

Converts the length values and angle values. The available units are:

  • "ft" ("feet", "foot")

  • "in" ("inch", "inches")

  • "m"

  • "cm"

  • "mm"

  • "rad"

  • "deg"

=vwu(4.0,"in") returns 101.60 mm, if length unit is set to mm and decimals are set to 2 in the Options dialog box

=vwu(2.0,"rad") returns 114.59 degrees, if angle is set to degrees and decimals are set to 2 in the Options dialog box

Note:

The units depend on the settings in File menu > Settings > Options > Units and decimals.

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 *, ?, and [ ] with the match function.

=match(P1, "PL100*10") returns 1

Accept all profiles starting with PFC: =match(P4, "PFC*")

Accept profiles starting with PFC, and height starts with 2, 3, 4 or 5: =match(P4, "PFC[2345]*")

Accept profiles starting with PFC, heights are 200, 300, 400 or 500 and width starts with 7: =match(P4, "PFC[2345]00?7*")

length(parameter)

Returns the number of characters in the parameter.

=length(P1) returns 8

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.

=find(P1, "*") returns 5

getat(parameter, n)

Returns the n:th (starting at zero) character from the parameter.

=getat(P1, 1) returns "L"

setat(parameter, n, character)

Sets the n:th (starting at zero) character to the specified character in the parameter.

=setat(P1, 0, "B") returns "BL100*10"

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.

=mid(P1,2,3) returns "100"

reverse(string)

Reverses the given string.

=reverse(P1) returns "01*001LP"

replace(source string, old substring, new substring)

Replaces all specified substrings with another string.

=replace(P1," ","") would remove all of the space characters from the 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

=sin(d45) returns 0.71

cos()

Returns the cosine value

=cos(d45) returns 0.71

tan()

Returns the tangent value

=tan(d45) returns 1.00

asin()

Inverse function of sin(), return value in radians

=asin(1) returns 1.571 rad

acos()

Inverse function of cos(), return value in radians

=acos(1) returns 0 rad

atan()

Inverse function of tan(), return value in radians

=atan(1) returns 0.785 rad

sinh()

Returns the hyperbolical sine value

=sinh(d45) returns 0.87

cosh()

Returns the hyperbolical cosine value

=cosh(d45) returns 1.32

tanh()

Returns the hyperbolical tangent value

=tanh(d45) returns 0.66

atan2()

Returns the angle whose tangent is the quotient of the two numbers. Return value in radians

=atan2(1,3) returns 0.32

Note:

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) or sin(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).

=fMarketSize("S235JR", 10, 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.

=fAD("skew","ID50B8559A-0000-010B-3133-353432373038") returns 45

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("slope","ID50B8559A-0000-010B-3133-353432373038")

fAD("cant", GUID)

Returns the cant angle of rotated secondary part whose GUID is given.

=fAD("cant","ID50B8559A-0000-010B-3133-353432373038")

Note:
  • 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

  1. Column
  2. Beam
  3. Slope
  4. 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

  1. Skew
  2. Slope
Was this helpful?
Previous
Next