<?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: Save preferences with ACAPI_SetPreferences(ver, size, preferences) where prefs contains a hashta in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-preferences-with-ACAPI-SetPreferences-ver-size-preferences/m-p/309437#M1833</link>
    <description>&lt;P&gt;Yes, this is because GS::HashTable contains dynamically allocated data. DG_Test just writes it to the preferences based on the static size of the struct:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;ACAPI_SetPreferences (CURR_ADDON_VERS, sizeof (MyPrefs), (GSPtr) &amp;amp;prefsData);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have complex structures in your class, you have to serialize it to a binary blob, and write that one in preferences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find a detailed explanation here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://archicadapi.graphisoft.com/Archicad-maze-generator-add-on-tutorial-part-3" target="_blank" rel="noopener"&gt;https://archicadapi.graphisoft.com/Archicad-maze-generator-add-on-tutorial-part-3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 Oct 2021 13:40:30 GMT</pubDate>
    <dc:creator>Viktor Kovacs</dc:creator>
    <dc:date>2021-10-15T13:40:30Z</dc:date>
    <item>
      <title>Save preferences with ACAPI_SetPreferences(ver, size, preferences) where prefs contains a hashtable;</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-preferences-with-ACAPI-SetPreferences-ver-size-preferences/m-p/309403#M1832</link>
      <description>&lt;P&gt;I noticed in the DG_Test Example project that the &lt;EM&gt;MyPrefs&amp;nbsp;&lt;/EM&gt;struct is made only from static variables. For some time I am struggling to Debug my code for saving this kind of struct into the preferences.&amp;nbsp;&lt;BR /&gt;In the hashtable below I want to store multiple dialog Item settings, of the same class. I keep getting memory errors. Is this because I am trying to change the memory dynamically, by adding elements to the HashTable?&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;typedef struct {
	Int32				version;
	API_AttributeIndex	layer;
	API_AttributeIndex	hatchLineType;
	API_AttributeIndex	hatchFill;
	short				hatchPen;
	short				hatchbkgPen;
	short				hatchContPen;
	bool				hatchGlobal;
	bool				hatchWithArea;
	short				filler;
    GS::HashTable&amp;lt;Type1, short&amp;gt; someStuffToKeepHere;//This is what I want to do.
} MyPrefs;&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 15 Oct 2021 07:15:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-preferences-with-ACAPI-SetPreferences-ver-size-preferences/m-p/309403#M1832</guid>
      <dc:creator>Mihalcea Bogdan</dc:creator>
      <dc:date>2021-10-15T07:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Save preferences with ACAPI_SetPreferences(ver, size, preferences) where prefs contains a hashta</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/Save-preferences-with-ACAPI-SetPreferences-ver-size-preferences/m-p/309437#M1833</link>
      <description>&lt;P&gt;Yes, this is because GS::HashTable contains dynamically allocated data. DG_Test just writes it to the preferences based on the static size of the struct:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="cpp"&gt;ACAPI_SetPreferences (CURR_ADDON_VERS, sizeof (MyPrefs), (GSPtr) &amp;amp;prefsData);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have complex structures in your class, you have to serialize it to a binary blob, and write that one in preferences.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can find a detailed explanation here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://archicadapi.graphisoft.com/Archicad-maze-generator-add-on-tutorial-part-3" target="_blank" rel="noopener"&gt;https://archicadapi.graphisoft.com/Archicad-maze-generator-add-on-tutorial-part-3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Oct 2021 13:40:30 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/Save-preferences-with-ACAPI-SetPreferences-ver-size-preferences/m-p/309437#M1833</guid>
      <dc:creator>Viktor Kovacs</dc:creator>
      <dc:date>2021-10-15T13:40:30Z</dc:date>
    </item>
  </channel>
</rss>

