We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2022-12-07 07:59 PM
I want to extract the materials of a wall I have currently selected
I only know that I get the selected elements with this code (i guess)
GS::Array<API_Neig> walls;
GSErrCode err = ACAPI_Selection_Get(nullptr, &walls, false, true, API_InsidePartially);
2022-12-08 11:52 AM - edited 2022-12-08 11:55 AM
API_Element element = {};
API_ModelElemStructureType structtype = {};
API_AttributeIndex constrinx = {};
double fillThick = 0;
BNZeroMemory(&element, sizeof(API_Element));
element.header.guid = elemGuid;
err = ACAPI_Element_Get(&element);
if (err != NoError) {return err;}
structtype = element.wall.modelElemStructureType;
if (structtype == API_CompositeStructure) constrinx = element.wall.composite;
if (structtype == API_BasicStructure) constrinx = element.wall.buildingMaterial;
fillThick = element.wall.thickness;
API_Attribute attrib;
API_AttributeDef defs;
BNZeroMemory(&attrib, sizeof(API_Attribute));
BNZeroMemory(&defs, sizeof(API_AttributeDef));
attrib.header.typeID = API_CompWallID;
attrib.header.index = constrinx;
err = ACAPI_Attribute_Get(&attrib);
if (err != NoError) {return err;}
err = ACAPI_Attribute_GetDef(attrib.header.typeID, attrib.header.index, &defs);
if (err != NoError) {return err;}
for (short i = 0; i < attrib.compWall.nComps; i++) {
/// you code for (*defs.cwall_compItems)[i].buildingMaterial, (*defs.cwall_compItems)[i].fillThick
}
ACAPI_DisposeAttrDefsHdls(&defs);
Structural engineer, developer of free addon for sync GDL param and properties
2022-12-08 12:36 PM - edited 2022-12-08 12:55 PM
Thanks for your code, but could you please explain the functions of every line. I am very new to the API, so I don't understand all of it.