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

How can I get area and volume of element components

kolioi
Booster

I have a generic wall with default parameters. When I open the All Components Schedule there is a list of all components of this wall. How can I get the area and the volume as displayed in the screenshot? Didn't find any sample code in the examples.

 

kolioi_2-1747397132722.png

 

6 REPLIES 6

Hi Kolioi,

 

I think you can get these values via ACAPI_Element_GetQuantities.

The composites member of the API_Quantities object should have exactly those values you are looking for.

 

Hope that helps,

Bernd

Hi Bernd,

 

This works for elements but not for their components.

In the above example I have a composite wall with 2 skins

 

kolioi_0-1747643245250.png

 

Here is my code

GS::Array<API_Guid> elemList;
GS::GSErrCode err = ACAPI_Element_GetElemList(API_WallID, &elemList, APIFilt_In3D);
for (USize i = 0; i < elemList.GetSize(); i++) {
	API_Element element{};
	element.header.guid = elemList.Get(i);
	err = ACAPI_Element_Get(&element);
	if (!err) {
			GS::Array<API_ElemComponentID> elemComponents;
			err = ACAPI_Element_GetComponents(element.header.guid, elemComponents);
			for (const auto& comp : elemComponents) {
				API_QuantityPar params;
				API_Quantities quantities;
				API_QuantitiesMask mask;
				API_ElementQuantity quantity{};

				quantities.elements = &quantity;

				ACAPI_ELEMENT_QUANTITY_MASK_SETFULL(mask);
				ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_SETFULL(mask);

				err = ACAPI_Element_GetQuantities(comp.componentID.componentGuid, &params, &quantities, &mask);

				ACAPI_ELEMENT_QUANTITIES_MASK_CLEAR(mask);
				ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_CLEAR(mask);
			}

	}
}


and ACAPI_Element_GetQuantities() returns APIERR_BADID (Incorrect elemGuid was specified / The passed identifier is not a valid one, or valid, but not proper for the given operation). If I pass the wall guid, the function returns correct values for the wall. However, I want to obtain the area and volume of the wall skins.

 

I was thinking about getting the quantities for the element wall and then checking quantities->composites.

 

BerndSchwarzenbacher_0-1747644779442.png

 

Did you try this too?

It's NULL

 

kolioi_0-1747645927826.png

Hm... you probably need to allocate the composites member first, like you did for the elements member.

 

API_Quantities quantities;
API_ElementQuantity quantity{};
quantities.elements = &quantity;
GS::Array<API_CompositeQuantity> compositeQuantities{};
quantities.composites = &compositeQuantities;

 

kolioi
Booster

OK, I found it in the examples.

 

Element_Test, Element_Snippets.cpp, Do_CalcQuantities()