Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Get all wall composites

Emkave
Enthusiast

Good day to everybody. I have a struggle with retrieving the whole data about wall composites that exist in an Archicad project.
Here is the empty Archicad project:

 

Emkave_0-1739533001391.png

 

and here is the list of wall composites:

Emkave_1-1739533101190.png

 

I will be really glad if somebody tells me a way how to get all of the composites without passing an element or guid or any other data to the API. I just want to make a code that would return me the list of all existing wall composites.

Thank you in advance!

 

Operating system used: Windows 11

15 REPLIES 15

Thank you very much for the correction of the topic's placement

 
 

 

 

Solution

Hi Emkave,


This code prints the composite names to the session report (works for AC27+):

ACAPI_Attribute_EnumerateAttributesByType (API_CompWallID,
    [](API_Attribute& compAttr)
{
    ACAPI_WriteReport (compAttr.header.name, false);
});

 

For more details about handling attributes or how to do this for older AC versions you can check the "Attribute_Test" example project in the respective API DevKits.

Or feel free to ask more for more details.

Best,
Bernd

Hello. Thank you for the reply. Is there a function for archicads of versions 26 and below?

Solution

Something like this should work in <=AC26 (not tested):

 

API_AttrTypeID typeID = API_CompWallID;

API_AttributeIndex num = 0;
GSErrCode err = ACAPI_Attribute_GetNum (typeID, &num);
if (err != NoError) { return err; }

for (API_AttributeIndex id = 1; id <= num; ++id) {
  API_Attribute attr{};
  attr.header.typeID = typeID;
  attr.header.index = id;

  GS::UniString tmpUniString;
  attr.header.uniStringNamePtr = &tmpUniString;
  err = ACAPI_Attribute_Get (&attr);
  if (err == APIERR_DELETED || err == APIERR_BADINDEX) { continue; }
  if (err != NoError) { return err; }

  ACAPI_WriteReport (tmpUniString, false);
}

 

Emkave
Enthusiast

Thanks to BerndSchwarzenbacher! Both solutions worked as I actually wanted! Thanks a lot.
Btw, I also wonder if I can actually extract the composite if I have actually selected an element. I was inspecting the memo of the selected element and the only information I found there about the composites were an integer values. I guess I have to pass them to API_Attribute attr {} variable as well. Hope my intuition is correct.

Thanks anyway!

Happy to help 🙂

Your intuition is correct. An element only stores the attribute index of a component. So set the index in API_Attribute attr{} and then use ACAPI_Attribute_Get. Also be aware of ACAPI_Attribute_GetDef & ACAPI_Attribute_GetDefExt for more details of attributes.

Setup info provided by author