2025-02-14
12:41 PM
- last edited on
2025-02-18
03:33 PM
by
Laszlo Nagy
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:
and here is the list of wall composites:
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
Solved! Go to Solution.
2025-02-18 03:35 PM
Thank you very much for the correction of the topic's placement
2025-02-19 07:52 PM
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
2025-02-19 08:10 PM
Hello. Thank you for the reply. Is there a function for archicads of versions 26 and below?
2025-02-19 10:25 PM - edited 2025-02-19 10:26 PM
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);
}
4 weeks ago
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!
4 weeks ago
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.