Search and Replace in Variants
A variant is described by various attributes, some of which are identical or almost identical for all sub-types. Examples of this are the file name or the order note.
In practice, it can happen that a series of attributes must be changed in several variants. In this case, it would be very time-consuming to open and adjust each variant individually.
In this case, the Variant Editor offers the possibility of searching several variants for an attribute and replacing the current value with another one.
Call and procedure
The Search & Replace is done via the command line call of the Variant Editor with the call parameter searchAndReplace. This is used as follows:
VariantenEditor.exe /searchAndRepalace path\search_parameters.txt path\list_of_variants.txt
Two files are required for the call:
- search_parameters.txt
This file contains control and search parameters and must be in TXT format iUTF-16 Little Endian with BOM encoding. Here you must work with a suitable text editor, e.g. Notepad ++.
Instead of search_parameters enter the name of the corresponding file. path is the complete path to this file. More about the structure of the file can be found in the section The search_parameters file.
- list_of_variants.txt
This file contains the list of parts to be changed. It must be in TXT format, also in UCS-2 LE BOM coding. Instead of list_of_variants, enter the name of the corresponding file. path is the complete path to this file. More on the structure of the file can be found in the section The list_of_variants file.
If you start the Variant Editor as indicated above, it first goes through each line of the search_parameters.txt file and reads in the attributes. Then it goes through each line of the file list_of_variants.txt to read in the parts/variants to be changed. It checks whether the opening and reading of the files works and whether they are empty or contain all the necessary attributes.
If all tests are successful, a backup copy is created for each variant file. These backup copies are given the file extension .BAK. Now the editor goes through each variant step by step and searches for the attributes with the specified values. If there is a hit, the function replaces the old value with the new one. After the last variant has been run through, the process is automatically terminated.
To facilitate diagnosis in the event of an error, all steps are logged in a log file. The path and file name of this file are displayed in the console at the end. The log file can be found in the temp folder of the HiCAD installation directory.
If necessary, a manual HELiOS login is required.
The search_parameters file
The file is divided into two sections.
Part 1
The first part defines the control parameters for the behaviour of the Search & Replace function. The lines have the following structure:
Control attribute name: Value
Blank lines and lines beginning with the # character are ignored. In this way, parameters can be (de)activated quickly and easily.
The control attribute name refers to an attribute that controls the variant change process. These are described via attributes that begin with the prefix VAREDIT_.
Attribute |
Explanation |
---|---|
VAREDIT_LANGUAGE_CODE |
The value for a HELiOS attribute name can be in the variant in several languages. The language code matching the HiCAD language must be entered after this attribute, e.g. 1031 for German. 1033 for English or 1036 for French. This parameter is mandatory and is set to 1031 by default. |
VAREDIT_BASE_DIR |
Here you can specify the directory in which the variant files are located. As a rule, this will be the path to the HiCAD PlantParts directory. This parameter is mandatory and is assigned by default with the PlantParts folder in the installation directory. |
VAREDIT_DRY |
This attribute can be used to control whether the variant file should actually be changed or not. The truth value 1 pretends to browse and change the variant, but the file remains unchanged at the end. This parameter is optional and is set to 1 by default. |
VAREDIT_REGEX |
If the truth value of this attribute is set to 1, then regular expressions are included in the search parameters. If not set, then the expressions are ignored. This parameter is optional and is set to 0 by default. |
VAREDIT_UPD_REVID |
If the truth value of this attribute is set to 1, then a HELiOS query for the revision is performed for the variant. This only happens if the part's Head ID is also changed. This parameter is optional and is set to 1 by default. |
The block ,for the control parameters could, for example, look as follows:
# Block of control parameters VAREDIT_LANG_CODE:1033 VAREDIT_BASE_DIR:C:\HiCAD\PlantParts\ VAREDIT_DRY:1 VAREDIT_REGEX:1 VAREDIT_UPD_REVID:1 |
Part 2
The second part defines the search parameters for the actual Search & Replace. The lines have the following structure:
HELiOS attribute name:Search value;Replace value
The HELiOS attribute name refers to an attribute that is used in the variants, e.g. BENENNUNG (= Designation). Instead of a HELiOS attribute name, you can also specify a variable name directly, e.g. N instead of NENNWEITE (= Nominal diameter).
You cannot use the language-dependent attribute identifiers displayed in the variant editor, such as sheet thickness etc!
Spaces in the values are not ignored, but read in as written there.
The block for the search parameters could, for example, look as follows:
# Block of search parameters CNT1:20100;10000 PN:40;50.569 D1:90;120.666 HEL_SACHNUMMER:EN 1092-1/01/DN <NENNWEITE>/PN 40;EN 1092-1/01/DN <DRUCK>/PN <DRUCK> BENENNUNG:(Clean)[^ ]*( for welding);\1break\2 HEL_KOPFID:B00DH4XULBEB5J00003HVV;B00DH4XULBEB5J00003HLP |
Floating point values (Decimal fractions) must be separated with a point and not with a comma!
The list_of_variants file
As mentioned above, this file lists the variants to be changed with their file name and extension. Each line may only contain one file at a time.
Empty lines and lines beginning with the character # are ignored. Thus, variants can be (de)activated quickly and easily.
The content of the list of variants could, for example, look as follows:
# List of variants EN1092-1-01-PN25.vaa EN1092-1-01-PN40.vaa EN1092-1-01-PN63.vaa |
Example
In this example we assume that the .txt files are located in a directory D:\temp and have the correct encoding.
Step 1: Configure the search_parameters file
Here you can now adjust the parameters almost arbitrarily.
Step 2: Fill the list_of_variants list file
Tip:
To copy several file names in Windows Explorer, select them and choose Copy as path from the context menu. You can then paste this copy into the variant list (Quotation marks and path must be removed manually.).
Step 3: Calling the Variant Editor
The variant editor is now started in the HiCAD exe directory via command line call.
VariantenEditor.exe /searchAndReplace d:\temp\search_parameters.txt d:\temp\list_of_variants.txt
Now the variant editor is started and a HELiOS login is performed. After that, the rest runs in the background. In the command line, the path to the log file is displayed at the end.
The resulting log file shows which steps were successful and where there were problems. The contents of the file are as follows: