<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Wall Quantities Extraction in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602668#M9333</link>
    <description>&lt;P&gt;Dear fellow Archicad C++ Users,&lt;/P&gt;
&lt;P&gt;I am trying to extract the Quantities of walls (particularly composite walls). I followed the example folder Element_Snippets. But I am stuck, please I need help. I have tried several code setups some crashed but only this one gave me a WriteReport Dialog page but with Wall GUIDs but no Composite as output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please here is my code, any useful help and guidance is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;void ExtractCompositeWallQuantities1() {
    GS::Array&amp;lt;API_Guid&amp;gt; wallGuids;
    ACAPI_Element_GetElemList(API_WallID, &amp;amp;wallGuids, APIFilt_OnActFloor);

    char reportBuffer[4096];
    BNZeroMemory(reportBuffer, sizeof(reportBuffer)); // Initialize reportBuffer with zeros

    char wallBuffer[512];
    BNZeroMemory(wallBuffer, sizeof(wallBuffer)); // Initialize wallBuffer with zeros

    strcat(reportBuffer, "Composite Wall Quantities:\n");

    for (const auto&amp;amp; wallGuid : wallGuids) {
        API_Quantities quantities;
        

        API_QuantitiesMask mask;
        BNZeroMemory(&amp;amp;mask, sizeof(mask)); // Initialize mask with zeros
        API_QuantityPar params;
        BNZeroMemory(&amp;amp;params, sizeof(params)); // Initialize params with zeros

        ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_CLEAR(mask); // Clear the composites part of the mask
        ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_SETFULL(mask); // Set the composites part of the mask to full


    	params.minOpeningSize = EPS;
        GSErrCode err = ACAPI_Element_GetQuantities(wallGuid, &amp;amp;params, &amp;amp;quantities, &amp;amp;mask);
        if (err == NoError) {
            const GS::Array&amp;lt;API_CompositeQuantity&amp;gt;* compositeQuantities = quantities.composites; // Dereference the pointer
            if (compositeQuantities) {
                for (UInt32 i = 0; i &amp;lt; compositeQuantities-&amp;gt;GetSize(); ++i) {
                    const API_CompositeQuantity&amp;amp; compositeQuantity = (*compositeQuantities)[i];
                    double const wallVolume = compositeQuantity.volumes;
                    double const wallProjectedArea = compositeQuantity.projectedArea;
                    sprintf(wallBuffer, "Wall GUID: %s, Composite Index: %d, Volume: %.3lf, Projected Area: %.3lf\n",
                        APIGuidToString(wallGuid).ToCStr().Get(), i, wallVolume, wallProjectedArea);
                    strcat(reportBuffer, wallBuffer);
                }
            }
            else {
                strcat(reportBuffer, "No composite quantities available for wall GUID: ");
                strcat(reportBuffer, APIGuidToString(wallGuid).ToCStr().Get());
                strcat(reportBuffer, "\n");
            }
        }
        else {
            strcat(reportBuffer, "Failed to get quantities for wall GUID: ");
            strcat(reportBuffer, APIGuidToString(wallGuid).ToCStr().Get());
            strcat(reportBuffer, "\n");
        }
    }

    ACAPI_WriteReport(reportBuffer, true);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 12:51:01 GMT</pubDate>
    <dc:creator>Apollos</dc:creator>
    <dc:date>2024-09-16T12:51:01Z</dc:date>
    <item>
      <title>Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602668#M9333</link>
      <description>&lt;P&gt;Dear fellow Archicad C++ Users,&lt;/P&gt;
&lt;P&gt;I am trying to extract the Quantities of walls (particularly composite walls). I followed the example folder Element_Snippets. But I am stuck, please I need help. I have tried several code setups some crashed but only this one gave me a WriteReport Dialog page but with Wall GUIDs but no Composite as output.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please here is my code, any useful help and guidance is appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;void ExtractCompositeWallQuantities1() {
    GS::Array&amp;lt;API_Guid&amp;gt; wallGuids;
    ACAPI_Element_GetElemList(API_WallID, &amp;amp;wallGuids, APIFilt_OnActFloor);

    char reportBuffer[4096];
    BNZeroMemory(reportBuffer, sizeof(reportBuffer)); // Initialize reportBuffer with zeros

    char wallBuffer[512];
    BNZeroMemory(wallBuffer, sizeof(wallBuffer)); // Initialize wallBuffer with zeros

    strcat(reportBuffer, "Composite Wall Quantities:\n");

    for (const auto&amp;amp; wallGuid : wallGuids) {
        API_Quantities quantities;
        

        API_QuantitiesMask mask;
        BNZeroMemory(&amp;amp;mask, sizeof(mask)); // Initialize mask with zeros
        API_QuantityPar params;
        BNZeroMemory(&amp;amp;params, sizeof(params)); // Initialize params with zeros

        ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_CLEAR(mask); // Clear the composites part of the mask
        ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_SETFULL(mask); // Set the composites part of the mask to full


    	params.minOpeningSize = EPS;
        GSErrCode err = ACAPI_Element_GetQuantities(wallGuid, &amp;amp;params, &amp;amp;quantities, &amp;amp;mask);
        if (err == NoError) {
            const GS::Array&amp;lt;API_CompositeQuantity&amp;gt;* compositeQuantities = quantities.composites; // Dereference the pointer
            if (compositeQuantities) {
                for (UInt32 i = 0; i &amp;lt; compositeQuantities-&amp;gt;GetSize(); ++i) {
                    const API_CompositeQuantity&amp;amp; compositeQuantity = (*compositeQuantities)[i];
                    double const wallVolume = compositeQuantity.volumes;
                    double const wallProjectedArea = compositeQuantity.projectedArea;
                    sprintf(wallBuffer, "Wall GUID: %s, Composite Index: %d, Volume: %.3lf, Projected Area: %.3lf\n",
                        APIGuidToString(wallGuid).ToCStr().Get(), i, wallVolume, wallProjectedArea);
                    strcat(reportBuffer, wallBuffer);
                }
            }
            else {
                strcat(reportBuffer, "No composite quantities available for wall GUID: ");
                strcat(reportBuffer, APIGuidToString(wallGuid).ToCStr().Get());
                strcat(reportBuffer, "\n");
            }
        }
        else {
            strcat(reportBuffer, "Failed to get quantities for wall GUID: ");
            strcat(reportBuffer, APIGuidToString(wallGuid).ToCStr().Get());
            strcat(reportBuffer, "\n");
        }
    }

    ACAPI_WriteReport(reportBuffer, true);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 12:51:01 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602668#M9333</guid>
      <dc:creator>Apollos</dc:creator>
      <dc:date>2024-09-16T12:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602674#M9334</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/8527"&gt;@BerndSchwarzenbacher&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Please do you have any counsel relating to Composite Wall Quantities?&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 01:28:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602674#M9334</guid>
      <dc:creator>Apollos</dc:creator>
      <dc:date>2024-05-06T01:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602791#M9338</link>
      <description>&lt;P&gt;After this line:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;API_Quantities quantities;&lt;/LI-CODE&gt;
&lt;P&gt;…add:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;CompositeQuantityList composites;
quantities.composites = &amp;amp;composites;&lt;/LI-CODE&gt;
&lt;P&gt;&lt;EM&gt;ACAPI_Element_GetQuantities&lt;/EM&gt; won't populate this variable for you - leaving it as &lt;EM&gt;nullptr&lt;/EM&gt; indicates you aren't interested in those quantities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then instead of this:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;const GS::Array&amp;lt;API_CompositeQuantity&amp;gt;* compositeQuantities = quantities.composites;&lt;/LI-CODE&gt;
&lt;P&gt;…just use the existing &lt;EM&gt;composites&lt;/EM&gt; variable.&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 16:00:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602791#M9338</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2024-05-06T16:00:41Z</dc:date>
    </item>
    <item>
      <title>Re: Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602792#M9339</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/733"&gt;@Ralph Wessel&lt;/a&gt;&amp;nbsp;. I will try out what you advised. Even though I also tried&amp;nbsp;ACAPI_Element_GetMoreQuantities() as described in the Documentation but still not successful. I try out your suggestion I hope all goes. Please, here is the extra code I tried but no result. Please, where do you think I made a mistake?&amp;nbsp; Please I use Archicad 27 C++ API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;void CompositeWallQuantitiesExtraction()
{
    
    API_Element element;
	GS::Array&amp;lt;API_CompositeQuantity&amp;gt; composites;
    GS::Array&amp;lt;API_Quantities&amp;gt; quantities;
    GS::Array&amp;lt;API_Guid&amp;gt;       elemGuids;
	API_QuantitiesMask        mask;
    API_QuantityPar           params;

    ACAPI_Element_GetElemList(API_WallID, &amp;amp;elemGuids, APIFilt_OnActFloor);

    ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_CLEAR(mask);
    ACAPI_ELEMENT_COMPOSITES_QUANTITY_MASK_SETFULL(mask);

    quantities.Push(API_Quantities());
    quantities[0].composites = &amp;amp;composites;
    elemGuids.Push(element.header.guid);
    params.minOpeningSize = EPS;

	GSErrCode err = ACAPI_Element_GetMoreQuantities(&amp;amp;elemGuids, &amp;amp;params, &amp;amp;quantities, &amp;amp;mask);
    if (err != NoError) {
        ErrorBeep("ACAPI_Element_GetQuantities", err);
        return;
    }
    WriteReport("%s GUID:%s", ElemID_To_Name(API_WallID).ToCStr(CC_UTF8).Get(),
        APIGuidToString(element.header.guid).ToCStr().Get());

    for (UInt32 i = 0; i &amp;lt; composites.GetSize(); i++) {
        API_Attribute	attr;
        GS::UniString	cFlags;
        GSErrCode		err;

        attr = {};
        attr.header.typeID = API_BuildingMaterialID;
        attr.header.index = composites[i].buildMatIndices;

        err = ACAPI_Attribute_Get(&amp;amp;attr);
        if (err == NoError) {
            if ((composites[i].flags &amp;amp; APISkin_Core) != 0) {
                cFlags.Assign("Core");
            } if ((composites[i].flags &amp;amp; APISkin_Finish) != 0) {
                if (!cFlags.IsEmpty())
                    cFlags.Append("+");
                cFlags.Append("Finish");
            }
        }

        WriteReport("  	composite:   %s[%d]		- volume: %lf		- projected area: %lf	- flag: %s", attr.header.name, composites[i].buildMatIndices, composites[i].volumes, composites[i].projectedArea, static_cast&amp;lt;const char*&amp;gt; (cFlags.ToCStr()));
    }
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 May 2024 17:41:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/602792#M9339</guid>
      <dc:creator>Apollos</dc:creator>
      <dc:date>2024-05-06T17:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/603068#M9344</link>
      <description>&lt;P&gt;Dear&amp;nbsp;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/733"&gt;@Ralph Wessel&lt;/a&gt;&amp;nbsp;, please your recommendations did not achieve the expected task. May be I did not understand and therefore still omitting something. Thank you for being there to help.&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2024 11:05:20 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/603068#M9344</guid>
      <dc:creator>Apollos</dc:creator>
      <dc:date>2024-05-08T11:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/603699#M9367</link>
      <description>&lt;P&gt;Try processing the quantities element by element like this:&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;void CompositeWallQuantitiesExtraction() {
	GS::Array&amp;lt;API_Guid&amp;gt; elemGuids;
	if ((ACAPI_Element_GetElemList(API_WallID, &amp;amp;elemGuids, APIFilt_OnActFloor) != NoError) || elemGuids.IsEmpty())
		return;
	for (auto&amp;amp; guid : elemGuids ) {
		API_QuantityPar params{};
		params.minOpeningSize = eps;
		GS::Array&amp;lt;API_CompositeQuantity&amp;gt; comps;
		API_Quantities quants;
		API_ElementQuantity elemQuants{};
		GS::Array &amp;lt;API_ElemPartQuantity&amp;gt; elemPartQuantities;
		GS::Array &amp;lt;API_ElemPartCompositeQuantity&amp;gt; elemPartComposites;
		quants.elements = &amp;amp;elemQuants;
		quants.composites = &amp;amp;comps;
		quants.elemPartQuantities = &amp;amp;elemPartQuantities;
		quants.elemPartComposites = &amp;amp;elemPartComposites;
		API_QuantitiesMask mask;
		ACAPI_ELEMENT_QUANTITIES_MASK_SETFULL(mask);
		auto error = ACAPI_Element_GetQuantities(guid, &amp;amp;params, &amp;amp;quants, &amp;amp;mask);
		if (error != NoError)
			continue;
		for (auto&amp;amp; comp : comps) {
			//Process composite quants here
		}
	}
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 May 2024 19:44:54 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/603699#M9367</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2024-05-14T19:44:54Z</dc:date>
    </item>
    <item>
      <title>Re: Wall Quantities Extraction</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/603804#M9368</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.graphisoft.com/t5/user/viewprofilepage/user-id/733"&gt;@Ralph Wessel&lt;/a&gt;&amp;nbsp;. I will try you advice. I will get back to give you an update. Once again thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 15 May 2024 08:43:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Wall-Quantities-Extraction/m-p/603804#M9368</guid>
      <dc:creator>Apollos</dc:creator>
      <dc:date>2024-05-15T08:43:51Z</dc:date>
    </item>
  </channel>
</rss>

