<?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 Re: ACAPI_Element_AddClassificationItem function  - /C++ vs Python/ in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367794#M8539</link>
    <description>&lt;P&gt;My guess is that the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ACAPI_Element_AddClassificationItem&lt;/FONT&gt; function opens a command scope internally, so it creates thousands of undo steps. I'd try to wrap the entire loop with a&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ACAPI_CallUndoableCommand&lt;/FONT&gt; call and see if that helps.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jan 2023 16:46:59 GMT</pubDate>
    <dc:creator>kovacsv</dc:creator>
    <dc:date>2023-01-17T16:46:59Z</dc:date>
    <item>
      <title>ACAPI_Element_AddClassificationItem function  - /C++ vs Python/</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367748#M8538</link>
      <description>&lt;P&gt;Hello Everybody!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm developing an add-on that sets classification of items. It iterates an array with element GUIDS and classification GIUDS and sets the element to the matching classification. I use the ACAPI_Element_AddClassificationItem function and it works, but it is lightyears slower than the "seemingly" same function in the Python API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has anyone exeperienced something similar? Here's a piece of code:&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;GS::Array&amp;lt;GS::Pair&amp;lt;API_Guid, API_Guid&amp;gt;&amp;gt; finalElemClassification;

for (unsigned int i = 0; i &amp;lt; elementList.GetSize(); i++)
{
    if (classifications.ContainsKey(layerPrefixArray[i]))
    {
        finalElemClassification.Push(GS::Pair&amp;lt;API_Guid, API_Guid&amp;gt;(elementList[i], 
        classifications[layerPrefixArray[i]]));
    }
}

for (auto j : finalElemClassification)
{
    err = ACAPI_Element_AddClassificationItem(j.first, j.second);
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Up until the last loop there's no problem with speed and performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Meanwhile doing the same thing with the python API and using the SetClassificationsOfElements function to set the classification of elements is way faster.&lt;/P&gt;
&lt;P&gt;I'm testing this on a project with approximately 10000 elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also noticed that the python script uses all CPU threads while the C++ add-on uses only one...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has anyone any idea how I could improve the C++ code to reach the same speed? What am I doing wrong?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 10:57:51 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367748#M8538</guid>
      <dc:creator>SzokeFerenc</dc:creator>
      <dc:date>2024-09-17T10:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_Element_AddClassificationItem function  - /C++ vs Python/</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367794#M8539</link>
      <description>&lt;P&gt;My guess is that the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ACAPI_Element_AddClassificationItem&lt;/FONT&gt; function opens a command scope internally, so it creates thousands of undo steps. I'd try to wrap the entire loop with a&amp;nbsp;&lt;FONT face="courier new,courier"&gt;ACAPI_CallUndoableCommand&lt;/FONT&gt; call and see if that helps.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 16:46:59 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367794#M8539</guid>
      <dc:creator>kovacsv</dc:creator>
      <dc:date>2023-01-17T16:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_Element_AddClassificationItem function  - /C++ vs Python/</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367942#M8540</link>
      <description>&lt;P&gt;Thank you so much for the quick answer! I tried what you suggested and it works!&lt;/P&gt;&lt;P&gt;It was a very good lesson for me! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2023 22:36:52 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-AddClassificationItem-function-C-vs-Python/m-p/367942#M8540</guid>
      <dc:creator>SzokeFerenc</dc:creator>
      <dc:date>2023-01-18T22:36:52Z</dc:date>
    </item>
  </channel>
</rss>

