The Find and Replace Text Property Values tool finds values in text properties and replaces them with a new value. It can replace the whole value or only the part of the value that it finds. One run can handle several properties and several find values.
Typical uses are:
- Unifying the spelling of values. For example, with the default settings and the find values
EI 60andEI-60and the replace valueEI60, the values EI 60, EI-60 and ei-60 all become EI60. - Removing or changing a part of the values. For example, with Within Text and Starts With, the find value
EXT_and an empty replace value,EXT_Wall_200becomesWall_200. - Filling in missing values. For example, with Is Equal, empty find values and the replace value
Unknown, the objects that have no value for the property get the value Unknown.
How finding and replacing works
The tool compares the values of the properties listed in Target Properties with the Find Values, using the Find Operator. The Replace Type defines what is replaced when a value is found:
- With Whole Text, the whole value is replaced with the Replace Value. For example, with Contains, the find value
Concreteand the replace valueSteel, the valueConcrete wallbecomesSteel. - With Within Text, only the found part of the value is replaced, and the rest stays as it is. With the same settings,
Concrete wallbecomesSteel wall.
With Within Text, Contains and Matches replace every place where the find value is found, Starts With replaces only the beginning of the value and Ends With only the end. For example, with the find value AB and the replace value X, the value ABAB becomes XX with Contains, XAB with Starts With and ABX with Ends With.
Upper and lower case letters are treated as the same, unless you turn Case Sensitive ON.
Spaces at the start and end of a new value are removed. If the new value is empty, the property value is removed. Values that are not found stay as they are.
An object that has no value for the property is found only by Is Equal with empty Find Values, and by the operators that start with Is Not or Does Not. See Find Operator and Find Values below.
Several find values
How several find values are used depends on the Replace Type and the Find Operator:
- With Whole Text, a value is replaced when it matches any of the find values.
- The Is Not and Does Not operators, which are available with Whole Text, work the other way: a value is replaced only when it matches none of the find values. For example, Is Not Equal with the find values
EI30andEI60and the replace valueOtherkeeps the values EI30 and EI60, and changes all other values to Other. - With Within Text, the find values are used one after the other, in the listed order. Each find value works on the value as the earlier find values have already changed it. For example, with Contains, the find values
_and.and the replace value-, the valueW_01.AbecomesW-01-A.
What the tool reports
The tool does not report how many values it changed. It reports a warning and continues with the next property when:
- none of the Target Objects has a property with a name or identity key listed in Target Properties.
- a property listed in Target Properties is not a text property in some object classes. The warning lists these object classes. The property is still changed in the object classes where it is a text property.
If a setting is not valid, the tool reports an error and does not change the model. The settings below describe these cases.
Settings
Target Objects
Defines the objects whose property values are found and replaced. You can select, for example, the objects of an object class or a group. The default value is all objects.
Excluded objects are not changed. Objects that are Not Decided Yet are changed only if no objects have been included. You can read more about these in Include/Exclude Objects.
If the selection does not find any objects, the tool reports a warning and does not change the model.
Target Properties
Defines the properties in which the values are found and replaced. Use the name or the identity key of the property. This setting is mandatory. If it is empty, the tool reports an error and does not change the model.
You can list several properties. Type a single value directly into the box. To enter several values, click the list button at the right end of the box. The List Editor opens, where you enter one value per line. Spaces before and after the names are ignored, and empty lines are skipped. Upper and lower case letters are treated as the same, and wildcards are not supported.
If an object class has several properties with the same name, for example in different property sets, the tool changes all of them. To change only one of them, use its identity key.
The tool changes the property in the object classes of the Target Objects that have it. It does not add the property to the other object classes.
Only text properties with a single value are changed. Properties of other types, for example numbers, dates, Yes/No values or lists of values, are skipped with a warning. To find and replace in a number or another type of value, first copy the values to a text property with the Copy Property Values tool.
Replace Type
Defines whether the whole value or only the found part of it is replaced. The default value is Whole Text.
Whole Text
When a value matches a find value, the whole value is replaced with the Replace Value.
Within Text
Only the found part of the value is replaced with the Replace Value. The rest of the value stays as it is.
Find Operator
Defines how the values of the Target Properties are compared with the Find Values. There is one Find Operator setting for each Replace Type, and only the one of the selected Replace Type is shown:
- When the Replace Type is Whole Text, all the choices below are available. The default value is Is Equal.
- When the Replace Type is Within Text, only Contains, Starts With, Ends With and Matches are available. The default value is Contains.
Is Equal
Available with Whole Text. The value is replaced when it is equal to a find value. If Find Values is empty, the objects that have no value are found.
Contains
With Whole Text, the whole value is replaced when it contains a find value. With Within Text, every place where the find value occurs in the value is replaced.
Starts With
With Whole Text, the whole value is replaced when it starts with a find value. With Within Text, the find value at the start of the value is replaced.
Ends With
With Whole Text, the whole value is replaced when it ends with a find value. With Within Text, the find value at the end of the value is replaced.
Is Like
Available with Whole Text. The find values can contain wildcards, and the value is replaced when it matches a find value. The find value must match the whole value. For example, W-* matches W-101 but not XW-101. You can read more about the wildcards in Using wildcards (Like -operator).
Matches
The find values are regular expressions. With Whole Text, the whole value is replaced when the regular expression finds a match anywhere in the value. To require that the whole value matches, start the regular expression with ^ and end it with $, for example ^W-\d+$. With Within Text, every match in the value is replaced. For example, the find value \d+ and the replace value # change W-101-A into W-#-A.
If a find value is not a valid regular expression, the tool reports an error and does not change the model. You can read more in Using Regular Expressions.
Is Not Equal
Available with Whole Text. The value is replaced when it is not equal to any of the find values. If Find Values is empty, the objects that have a value are found.
Does Not Contain
Available with Whole Text. The value is replaced when it does not contain any of the find values.
Does Not Start With
Available with Whole Text. The value is replaced when it does not start with any of the find values.
Does Not End With
Available with Whole Text. The value is replaced when it does not end with any of the find values.
Is Not Like
Available with Whole Text. The value is replaced when it does not match any of the find values, which can contain wildcards.
Does Not Match
Available with Whole Text. The value is replaced when none of the regular expressions in Find Values finds a match in it. If a find value is not a valid regular expression, the tool reports an error and does not change the model.
The Is Not and Does Not operators also change the objects that have no value. An empty value does not match any find value, so these objects get the Replace Value too. The only exception is Is Not Equal with empty Find Values, which finds the objects that have a value.
Case Sensitive
If ON, upper and lower case letters must match exactly. If OFF, they are treated as the same, so the find value concrete also finds Concrete and CONCRETE. The setting applies to all the Find Operators. The default value is OFF.
The Replace Value is always used as you have written it. For example, with Within Text, Contains, the find value wall and the replace value door, the value a WALL and a wall becomes a door and a door.
Find Values
Defines the values to find in the Target Properties. With Is Like and Is Not Like they can contain wildcards, and with Matches and Does Not Match they are regular expressions.
You can list several values. Type a single value directly into the box. To enter several values, click the list button at the right end of the box. The List Editor opens, where you enter one value per line. How several values are used is described in Several find values above.
Spaces before and after each value are ignored, and empty lines are skipped. A find value therefore cannot start or end with a space. To find spaces, use Matches with a regular expression. For example, Within Text with Matches, the find value \s+ and an empty Replace Value remove all spaces from the values.
This setting is mandatory, except with Is Equal and Is Not Equal. With these two operators, empty Find Values stand for no value: Is Equal finds the objects that have no value, and Is Not Equal finds the objects that have a value. The Replace Value is then mandatory. With the other operators, empty Find Values make the tool report an error and leave the model unchanged.
Replace Value
Defines the value that replaces the found value. With Whole Text, it becomes the new value of the property. With Within Text, it replaces the found part of the value. The default value is empty.
If the Replace Value is empty, the found value is removed. With Whole Text, the property value is removed. With Within Text, the found part is removed, and if nothing is left, the property value is removed. A Replace Value that contains only spaces counts as empty. The Replace Value cannot be empty when Find Values is empty. In that case the tool reports an error and does not change the model.
With Within Text and Matches, you can use the groups of the regular expression in the Replace Value: $1 stands for the text of the first group, $2 for the second and so on. For example, the find value (\d+)x(\d+) and the replace value $2x$1 change 900x2100 into 2100x900. Because of this, a $ in the Replace Value has a special meaning with Within Text and Matches. Use $$ to get a single dollar sign.
Release Notes
This tool was added in Simplebim 12.0 SR2
Comments
0 comments
Please sign in to leave a comment.