Get the index of a layer in an ARCHICAD project.

Call:

int ires = ac_request("layer","get_index", string slayername);



Here:

slayername - the name of the layer from which you want to get the index.

ires returns 0 if the call was made without errors,

or a negative value if an error occurred or there is no such layer in the project.

the layer index is obtained by the ac_getnumvalue() function;


Example.

Get the index of the layer "01 10 Bearing walls", if there is no such layer, then create it and display it in the message window.


string slayername = "01 10 Load-bearing walls";
int ires = ac_request("layer","get_index",slayername);
if(ires < 0)
{
   // layer not exist - create it
   ires = ac_request("layer","create",slayername);
   if(ires == 0)
      {
         ires = ac_request("layer","get_index",slayername);
      }
      else
      {
         cout<<"can't create layer"<<slayername;
         return -1;
      }
}

int iLayerIndex = ac_getnumvalue();
cout << "Index of the layer=" << iLayerIndex << "\n";