Assignment rules

These rules are used when assigning values to attributes or coordinates in point group edit and code table.

With both coordinates and attributes operations +, -, * and / can be used. For example, +100 adds one hundred to the value and /1000 divides the value by one thousand. Additionally, attributes and texts can be joined together with the &-operation. For example, AB& adds AB to the beginning of the value or &CD adds CD to the end. Joining attributes together works same way. For example, $T2& adds line number to the beginning.

Part of the attribute value can be removed with the §-operation. For example, operation 2§ removes two characters from the beginning of the value and operation §2 removes two characters from the end of the value. Known suffix can be removed by first searching it (e.g. LEVEL*) and then removing correct amount of characters (e.g. 5§).

+100                 Add 100 to original value.
/1000                Divide original value by 1000.
AB&                  Add prefix AB to original value.
&CD                  Add suffix CD to origial value.
2§                   Remove two leading characters.
§2                   Remove two trailing characters.

Square brackets can be used to pick part of the value. Start and end positions are given within brackets separated by semicolon. Indexing starts from zero and end position is first character not included with result. For example, operation [1:2] picks second character from the value. Either position can be omitted. Start position defaults to zero and end position defaults to value length. For example, [:2] picks first two characters and [2:] the rest starting from third character.

If end position is greater than value length, result may be shorter than difference of positions. Positions can also be negative. Negative positions are calculated from the end of value. Last character index is then -1.

$ID[1:3]             Pick two characters starting from second character.
$ID[1:]              Pick end part starting from second character.
$ID[:3]              Pick first three characters.
$ID[-2:]             Pick last two characters.
$ID[:-2]             Pick everything except last two characters.

Negative value can be given inside quotes ("-2"). More generally, quotes can be used to eliminate any special character handling. Values can be moved between all coordinates and attributes and they can be used with calculations. For example, value $HEIGHT gets the value of the HEIGHT-attribute or value -$DEPTH subtracts the value of the DEPTH-attribute. Syntax $# can be used to get attribute real value from the code file (e.g. $#T3 gets code description or $#MAT gets material name).

"-2"                 Set negative value -2.
"AB&"                Set value containing character &.
$HEIGHT              Get value from attribute HEIGHT in same point.
-$DEPTH              Subtract attribute DEPTH from original value.
$#T3                 Gets code description from the code file.

Conditional assignment can made with operators ? and !. Operator ? assigns value only if the attribute already have some value and operator ! assigns value only to empty attributes. This works also with coordinate values by checking if they are zeroes. Attribute value can be moved to an other attribute with operator ¤. Technically this is same as assigning attribute value to an other attribute and removing the original attribute.

?+100                Add 100 to original value, if it is not empty.
!1000                Assign value to attribute, if it is empty.
?-$DEPTH             Subtract attribute DEPTH only from existing values.
¤CODE                Assign attribute CODE value and remove CODE.

Macros

It is also possible to assign macro values to attributes.

#ID                  Assign object id (T2 or T4).
+#ANGLE              Add point angle to original value.

Instead of storing the macro value to attribute, macro itself can be stored by quoting it ("#SLOPE"). Macro values can also be used to search points with attribute method.

Format

Macros and attributes can be formatted in assignment using common value formatting rules. Angles and directions in attributes and macros are in gons by default.

#AREA%.1             Area with one decimal.
#SLOPE%q.2           Slope as ratio with two decimals.
$DIRECTION%d.1       Direction as degrees with one decimal.

Formatting can also contain field width and fill character using Text format rules.

$T4@8               123             Align right, fill with spaces
$T4@-8=0       12300000             Align left, fill with zeroes
X@14=.         ....123456.789       Align right, fill with points