Get full layer name from partial fragment.

Required when users agree to name layers in ARCHICAD with numeric or text prefixes.

For example, the "Apartments" layer could be written as "01 Apartments" or "20 Apartments". This approach occurs when the user wants to set a convenient order for the layers in the project.

However, from the point of view of the program, these are completely different layers.

To avoid errors, it is convenient to use this function.

Call:

int ires = ac_request("get_layer_by_substring",string slayernamefragment, int from);
int ires = ac_request("get_layer_by_substring", string slayernamefragment, int from, int range);

Here:

slayernamefragment - a fragment in the name that exactly identifies the layer (eg "Apartments").

from - sequence number of the symbol from the beginning of the full name of the layer in the project, from which to start the comparison for compliance.

range - the number of characters to check.

ires - 0 if the layer is found.

The full name of the found layer is read by the ac_getstrvalue() command;

Example.

Get the full name of the "Apartments" layer in the project, if it is known that the organization has a custom for sorting layers to use a prefix like "01 ".


string smalllayername="Apartments";
string longlayername;
ires = ac_request("get_layer_by_substring",smalllayername,3); // start comparison from 3rd position
if(ires != 0) {
tsalert(-1,"Runtime error","Layer not found",smalllayername);
cout << "!!!!!!!!!!!! Error: Layer not found - "<< smalllayername << "\n";
}
longlayername = ac_getstrvalue(); // read full layer name