• No results found

Functions to use in formulas

In document Tekla Structures Detailing Manual (Page 82-90)

This section lists all the functions you can use in formulas in custom components. Formulas always begin with the equals character (=). You can use the following functions in formulas:

Reference function (p. 83)

Mathematical functions (p. 84)

Statistical functions (p. 85)

Data type conversions (p. 86)

String operations (p. 86)

Trigonometric functions (p. 88)

Framing condition functions (p. 88)

Arithmetic operators

You can use the following arithmetic operators:

Operator Description Notes

+ addition Use also to create strings of parameters.

- subtraction

Logical statement

You can use if-then-else statements to test a condition and set the value according to the result:

You can also use the operators && (the logical AND operator) and || (the logical OR operator) inside the if statement.

&& - both conditions must be true

|| only one condition must be true For example to use a value 6:

=if (D1==200 && D2<40) then 6 else 0 endif D1 must be 200 and D2 must be less than 40.

=if (D1==200 || D2<40) then 6 else 0 endif D1 must equal 200, or D2 must be less than 40.

Reference function

A reference function refers 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.

To ensure the function includes the correct parameters, cut and paste it from the Custom component browser:

1. Right-click the property in the Custom component browser and select Copy reference. 2. Right-click the Formula cell in the Variables dialog box and select Paste.

Note that template attribute and user-defined attribute names must be written inside double quotation marks:

* multiplication Multiplication is faster than division, so it is faster to use

=D1*0.5 rather than

=D1/2.

/ division

Operator Description Notes

=if (D1>200) then 20 else 10 endif

fP(propertyname, ObjectId)

Mathematical functions

The mathematical functions are:

Name Description Example

fTpl("template attribute", object ID)

Returns the value of template attribute with given object ID.

For a list of available template attributes, see Template attributes reference.

fTpl("WEIGHT",6290) returns the weight of object, whose ID is 6290.

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

Returns the value of user-defined attribute with given object ID.

fP("comment", 741) returns the user-defined attribute comment of object, whose ID is 741.

Name Description Example

fabs(parameter) Returns the absolute value of the specified parameter.

fabs(D1) returns 15 if D1 = -15 exp(power) Returns e raised to the

specified power.

exp(D1) returns 7.39 if D1=2

ln(parameter) Natural logarithm of the specified parameter (base number neper).

ln(P2) returns 2.71 if P2=15

log(parameter) Returns the logarithm of the specified parameter (base number 10).

log(D1) returns 2 if D1=100 sqrt(parameter) Returns the square root

of the specified parameter.

sqrt(D1) returns 4 if D1=16

mod(dividend, divider)

Modulo mod(D1, 5) returns 1

if D1=16 pow(base number,

power)

Returns base number raised to the specified power.

pow(D1, D2) returns 9 if D1=3 D2=2

Statistical functions

The statistical functions are:

hypot(side1,side2)

side1

hypotenuse

side2

hypot(D1, D2) returns 5 if D1=3 D2=4

n!() Factorial n!(4) returns 24

(=1*2*3*4) round(parameter,

accuracy)

Round off according to given accuracy.

round(P1, 0.1) returns 10.600

if P1=10.567 fMarketSize(materi

al, thickness, extrastep)

Returns the next available market size for the material from the marketsize.dat file, based on the thickness you specify.

Insert the material in the parentheses.

For extrastep enter a number to define the increment to the next size (default is 0).

fMarketSize("S235JR", 10, 0)

See also Using market sizes.

Name Description Example

Name Description

Example (P1=1.4 P2=2.3)

ceil() Returns the smallest whole number greater than or equal to the specified parameter.

ceil(P1) returns 2

floor() Returns the largest whole number less than or equal to the specified parameter.

floor(P1) returns 1

min() Returns the smallest of specified parameters.

min(P1, P2) returns 1.4 max() Returns the largest of specified

parameters.

max(P1, P2) returns 2.3 sum() Sum of specified parameters sum(P1, P2) returns 3.7

Data type conversions

Conversion functions perform conversions between the three supported data types, integers, doubles and strings.

String operations

Include string parameters inside double quotation marks within the argument list of string operations.

sqsum() Sum of squared parameters:

(parameter1)2 + (parameter2)2

sqsum(P1, P2) returns 7.25 ave() Average of parameters ave(P1, P2) returns 1.85 sqave() Average of squared parameters. sqave(P1, P2) returns 3.625 Name Description

Example (P1=1.4 P2=2.3)

Name Description

int() Conversion to integer. This is useful especially for calculating profile dimensions:

100.0132222000 -> 100 double() Converts data to a double string() Converts data to string imp() Converts imperial units to

millimeters

imp (1,1,1,2) meaning 1 foot 1 1/2 inches 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 vwu(value

, unit)

Converts the value to

millimeters. The available units are:

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

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

"m"

"cm"

"mm"

"rad"

"deg"

vwu(4.0, "in") returns 101.6 mm

When you handle strings in formulas, you must use quotation marks. For example, to define profile size PL100*10 with two variables P2=100 and P3=10 enter the formula as follows:

="PL"+P2+"*"+P3

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 given 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"

Tekla Structures handles bolt spacings as strings. To define bolt spacing, select variable type to distance list and enter the formula like this:

=P1+" "+P2

This results in 100 200, if P1=100 (length) and P2=200 (length).

Trigonometric functions

You can include trigonometric functions in the formulae. Be sure to include the unit using the following prefixes. 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)

Framing condition functions

The following functions return the skew, slope, and cant angle of the secondary beam relative to the main part (column or beam).

Name Description

sin() Sine

cos() Cosine

tan() Tangent

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() Hyperbolical sine

cosh() Hyperbolical cosine tanh() Hyperbolical tangent

atan2(,) Returns the angle whose tangent is the quotient of two specified numbers. Return value in radians

Name Description Example

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

fAD("skew", 12345) returns 45

where 12345 is the ID of the secondary part, which is in 45 degree angle to main part.

Beam to column Note that slope and skew are relative to a beam framing into a column.

Beam to beam If you are working with two beams, "slope" is actually the 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.

fAD("slope", ID) Returns the sloped angle of the secondary part, whose ID is given.

fAD("slope", 12345)

fAD("cant", ID) Returns the cant angle of rotated secondary part, whose ID is given.

fAD("cant", 12345)

Name Description Example

Side view Top view Slope Skew Column Beam

Limitations

These functions do not return positive and negative "slope" and "skew" values. So it is not possible to determine up or down "slope" and left or right "skew" with these functions.

Maximum skew angle to return is 45 degrees.

In document Tekla Structures Detailing Manual (Page 82-90)