Report Expressions
This document details the extensive report expressions which are used to filter BOM fields.
Report COLUMN Expressions
The COLUMN expression in a report can now contain functions and mathematical, relational and logical operations.
Mathematical Operators | ||
---|---|---|
+ | plus | Also used for string concatenation |
- | minus | |
* | multiply | |
/ | divide | |
^ | power |
Relational Operators | ||
---|---|---|
> | Greater than | |
>= | Greater than or equal | |
< | Smaller than | |
<= | Smaller than or equal | |
== | Equal | Can be used for number and string comparison |
!= | Not equal | Can be used for number and string comparison |
= | RegEx | Regular expression operator |
Functions | |
---|---|
If (Boolean, then, else) | If then else |
MapText (string) | Map one text to another |
Left (expression)
Right (expression) |
The expression operates on the component/port properties of what's connected left/right of a fastener |
Total (expression) | Rune the expression on every component grouped in a single report line and adds up the results |
DA (expression) | Runs the expression on drawing attributes |
Formatting values in a report
Any value in a report can be formatted using format specifiers. Formatting is done when a property name, expression or function is directly followed by a colon and a format specifier.
<property name> : <format specifier>
The format specifier not only formats a number but also may specify decorating text around the value.
Example: Format the property LENGTH (with value 25.625) | ||
---|---|---|
LENGTH | 25.625 | Display without formatting. |
LENGTH:".0000"" | 25.6250 | Display the value of the property LENGTH with 4 significant digits. |
LENGTH:"#'#.#/16\"" | 2'1.5/8" | Display the LENGTH property as feet/inch/fraction with 1/16 inch accuracy. |
LENGTH:"#.#/16'"" | 25.5/8" | Display LENGTH as inch/fraction with 1/16 inch accuracy. |
Example: Format the result of an expression | ||
---|---|---|
LENGTH + 1 | 26.625 | Display without formatting. |
(LENGTH + 1):"#.0000" | 26.6250 | Display with 4 significant digits. |
(LENGTH + 1):"#'#.#/16\"" | 2'2.5/8" | Display as feet/inch/fraction. |
(LENGTH = 1):"#.#/16\"" | 26.5/8" | Display as inch/fraction. |
Format Specifiers
A format specifier is a combination of #, 0, decimal point and other characters. In general, the # and 0 (zero) characters are used as value placeholders, all others are used as is.
Please see below for a few examples:
Integer formatting: Examples use 3.1 as input value
Spec | What does it do | Result |
---|---|---|
# | Format as integer. | 3 |
0# | Format as integer with at least 2 digits. Leading zeros will be used for numbers < 10. | 03 |
00# | Format as integer with at least 3 digits. Leading zeros will be used for numbers < 100 | 003 |
Decimal formatting: Examples use 3.014 as input value
Spec | What does it do | Result |
---|---|---|
#.# | Format as decimal with at most one digit after the decimal point. | 3 |
#.0 | Format as decimal with exactly one digit after the decimal point | 3.0 |
#.000 | Format as decimal with exactly three digits after the decimal point | 3.014 |
00#.00 | Format as decimal with leading zeros for number < 100 and exactly two digits after the decimal point. | 003.01 |
Imperial formatting: Examples use 61.625 as input value
Spec | What does it do | Result |
---|---|---|
#'#.#/16" | Format as feet/inch/fraction.
The first # is the placeholder for the feet part, the second # is the
placeholder for the inch part and the third # is the placeholder for the
fraction numerator. The 16 after the / specifies the accuracy for the fraction
denominator. Possible values are 2,4,8,16,32,64.
All of the characters between the placeholders and after the accuracy part are displayed as is. |
5'1.5/8" |
# Feet #-#/16 Inch | Same as above but with different unit display. | 5 Feet 1-5/8 Inch |
#-#/16" | Format as inch/fraction. Same as above except for feet display. | 61.5/8" |
#-#/16 Inch | 61-5/8 Inch | |
#'#80.#/16" | An integer value following the inch placeholder specifies an inch/feet threshold. Below the threshold the value is reported in inches. Above it feet are used. Normally only 24 would be optionally used in dimensioning. | 5'1.5/8" |
Formatting with conversion
Optional one can divide/multiply the input value. This is done by pre-pending the format specifier with /<number>. For instance: /12 divides the input value by 12 and then applies the formatting.
Spec | What does it do | Result |
---|---|---|
/12#.00ft. | Divide the input by 12 and format as a decimal with exactly 2 digits after the decimal point. The end result is decimal feet when used in an imperial project. | 18 -> 1.50 ft. |
/36#.00 yards | Same above except output in yards | 18 -> 05.yards |
/1000#.000 m | Output as meters with 3 significant digits. | 2500 -> 2.500 m |
In reporting the conversion can probably be done better using the new expression option: The conversion to yards: (LENGTH / 36):"#.00 yards"
Reserved properties in a report
A few properties get special handling in a report:
NEWLINE
NEWLINE is a pseudo property that insert a line break in a report column
SIZE, SIZE1, SIZE2, SIZE3
When used in reporting, SIZE1, SIZE2 and SIZE3 may not return the value expected. Sometimes the value returned is empty, sometimes it returns the value for another port.
Please see the table below:
Case | SIZE1 | SIZE2 | SIZE3 | SIZE |
---|---|---|---|---|
Single port component | SIZE1 | SIZE1 | ||
2 port non reducing component | SIZE1 | SIZE1 | ||
2 port reducing component | SIZE1 | SIZE2 | SIZE1xSIZE2 | |
3 port equal | SIZE1 | SIZE2 | SIZE1xSIZE2 | |
3 port branch reducing | SIZE1 | SIZE3 | SIZE1xSIZE3 | |
3 port run reducing | SIZE1 | SIZE2 | SIZE3 | SIZE1xSIZE2xSIZE3 |
3 port run/branch reducing | SIZE1 | SIZE2 | SIZE3 | SIZE1xSIZE2xSIZE3 |
The SIZER, SIZE1R, SIZE2R, SIZE3R pseudo properties are introduced to give the user more control when needed. These always return the value of the port.
Case | SIZE1R | SIZE2R | SIZE3R | SIZER |
---|---|---|---|---|
2 port non reducing component | SIZE1 | SIZE2 | SIZE1xSIZE2 | |
2 port reducing component | SIZE1 | SIZE2 | SIZE1xSIZE2 | |
3 port equal | SIZE1 | SIZE2 | SIZE3 | SIZE1xSIZE2xSIZE3 |
3 port branch reducing | SIZE1 | SIZE2 | SIZE3 | SIZE1xSIZE2xSIZE3 |
3 port run reducing | SIZE1 | SIZE2 | SIZE3 | SIZE1xSIZE2xSIZE3 |
3 port run/branch reducing | SIZE1 | SIZE2 | SIZE3 | SIZE1xSIZE2xSIZE3 |
Port sizes values are always formatted to the report diameter specification for the project unit unless specified differently by the user.
Quantity
QUANTITY for Length items is formatted to the report length specification for the project unit unless specified differently by the user.
QUANTITY is an implied accumulation property. When used in a report it is basically equivalent to Total (QUANTITY)
When multiple components are grouped into a single report line, the quantity values for those components are added up
Report functions explained
IF (<Boolean expression>, <then expression>, <else expression>)
The result of the <then expression> or <else expression> is returned depending on the result of the Boolean expression>
Boolean expression examples | |
---|---|
VAR > 6 | returns true if VAR is greater than 6 |
VAR > 6 && VAR < 10 | Returns true if VAR is greater than 6 AND VAR is less than 10 |
VAR > 6 || VAR < 4 | Returns true if VAR is greater than 6 OR VAR is less than 4 |
EC_CLASS=.*VALVE.* | Returns true if EC_CLASS contains the word VALVE. This is a regular expression |
(a * b) > c |
IF () example | |
---|---|
If (IE_TYPE=CT_BOLT, "M" + SIZE1, SIZE) | For bolts return the bolt diameter prepended with a "M" character (like M12). For all other items return a size string (like 200x100) |
TOTAL (<expression>)
The MapText function maps a text to another text. The following example maps the EC_CLASS property into something humanly readable:
The mapping are stored in a CFG file (for instance: style.cfg). Any text to be mapped is prefixed with MAPTEXT_.
The Left/Right function
The left/right functions can only be used in weld reports. We use the isometric snippet shown below to create a few example reports. We have a reducing butt weld TEE connected to pipes. There are 2 shop welds and 1 field weld.
We start with a basic weld type report showing id, size and type. The properties listed in the report definition refers to weld properties:
The next example shows the use of the LEFT/RIGHT functions in a weld report. Left and Right refer to the ports/components connected by the weld.
- Left refers to the component with the lowest IE_SEQID
- Left refers to a PIPE whenever a PIPE is part of the connection
The expression within the left/right function parenthesis is evaluated on the properties of the connected component.
Example: Add a column that shows the EC_CLASS of the connected components. Note that a single column is used with an expression using both LEFT and RIGHT functions.
The next example shows the use of the special property CM in the LEFT/RIGHT functions.
CM refers to the end prep of the connected port. In the below example a single column is used to list the end preps of the connected components:
The next example report shows something similar, here however two separate column lists the end preps. Also the MapText function is used to get a full end prep description:
The following mappings where added to the style.cfg enabling the MapText function to work:
MAPTEXT_PE = Plain End
MAPTEXT_BW = Butt Weld
DA (,expression>)
The DA function runs the expression on the drawing attributes instead of component attributes.
Practical Bolt Size Reporting Example
For a bolt, SIZE returns <bolt diameter> x <bolt length>
You could use the following to return only the diameter for bolts:
COLUMN = 25::if (IE_TYPE=CT_BOLT, SIZE1, SIZE) | Returns SIZE1 for bolts, SIZE for others. |
COLUMN = 25::if (IE_TYPE=CT_BOLT, "M" + SIZE1, SIZE) | Same as above but prepends the bolt diameter with a 'M' character. |
- To have a column in the
weld report that shows the connected end preps (llike BWxPE):
COLUMN = 14::left (CM) + "x" + right (CM)
- To have a column in the
weld report that shows the connected end preps (like Butt Weld x Sq. Cut):
COLUMN = 14::left (MapText(CM)) + "x" + right (MapText(CM))
- To display the length of
pipes in the BOM in meters instead of millimeters:
COLUMN = 14::Quantity / 1000 + "meters"
- To display the length of
pipes in the BOM in meters instead of millimeters with 2 digit accuracy:
COLUMN = 14::(Quantity / 1000):"#.00 meters"
- To use an alternative
description for reinforcement pads:
COLUMN = 60::if (EC_CLASS =="REINFORCEMENT", "reinforcement pad", IE_DESCRIPT)
Testing
All the expressions in expression.txt are evaluated and the results are written to c:/temp/expression.log
Please see the following expression.log.
Changes in expression functionality
COLUM = 30:A:<expression> | The A as a column flag/qualifier stood for ACCUMULATE. |
COLUM = 30:2:<expression> | An integer value as a column flag/qualifier specified the precision to use for numbers in the expression. |
DA("AttrName") DA(AttrName) |
In previous versions there
already was a DA function for getting a single drawing attribute. There the
drawing attribute name needed to be within double quotes.
Double quotes are still allowed for backward compatibility. |
FIX (AttrName, nrDigits) | Previous versions had this FIX function to format a number. |
The following examples show how report results are returned when using the deprecated functions listed above: