<?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 [SOLVED] API_BuildingMaterialType-&amp;gt;id crashes in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-API-BuildingMaterialType-gt-id-crashes/m-p/294411#M5037</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to access the ID of a building material through API_BuildingMaterialType.id. But the returned attribute got a null value for the id (also for manufacturer and description). (&lt;STRONG&gt;EDIT:&lt;/STRONG&gt; And also on API_Attribute.header-&amp;gt;uniStringNamePtr)&lt;BR /&gt;
&lt;PRE&gt;short cnt;
ACAPI_Attribute_GetNum(API_BuildingMaterialID, &amp;amp;cnt);
cnt++;
for (short i = 1; i &amp;lt; cnt; i++)
{
  API_Attribute attr;
  BNZeroMemory(&amp;amp;attr, sizeof(API_Attribute));
  attr.header.typeID = API_BuildingMaterialID;
  attr.header.index = i;
  err = ACAPI_Attribute_Get(&amp;amp;attr);
  if (err != NoError)
    continue;
  API_BuildingMaterialType bm = attr.buildingMaterial;
  if (!bm.id-&amp;gt;IsEmpty())    // &amp;lt;----------- crashes when accessed
    //...
  //...
}&lt;/PRE&gt;
This is for both AC18 and AC19.&lt;/DIV&gt;</description>
    <pubDate>Wed, 12 Jul 2023 19:06:11 GMT</pubDate>
    <dc:creator>ReignBough</dc:creator>
    <dc:date>2023-07-12T19:06:11Z</dc:date>
    <item>
      <title>[SOLVED] API_BuildingMaterialType-&gt;id crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-API-BuildingMaterialType-gt-id-crashes/m-p/294411#M5037</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;I am trying to access the ID of a building material through API_BuildingMaterialType.id. But the returned attribute got a null value for the id (also for manufacturer and description). (&lt;STRONG&gt;EDIT:&lt;/STRONG&gt; And also on API_Attribute.header-&amp;gt;uniStringNamePtr)&lt;BR /&gt;
&lt;PRE&gt;short cnt;
ACAPI_Attribute_GetNum(API_BuildingMaterialID, &amp;amp;cnt);
cnt++;
for (short i = 1; i &amp;lt; cnt; i++)
{
  API_Attribute attr;
  BNZeroMemory(&amp;amp;attr, sizeof(API_Attribute));
  attr.header.typeID = API_BuildingMaterialID;
  attr.header.index = i;
  err = ACAPI_Attribute_Get(&amp;amp;attr);
  if (err != NoError)
    continue;
  API_BuildingMaterialType bm = attr.buildingMaterial;
  if (!bm.id-&amp;gt;IsEmpty())    // &amp;lt;----------- crashes when accessed
    //...
  //...
}&lt;/PRE&gt;
This is for both AC18 and AC19.&lt;/DIV&gt;</description>
      <pubDate>Wed, 12 Jul 2023 19:06:11 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-API-BuildingMaterialType-gt-id-crashes/m-p/294411#M5037</guid>
      <dc:creator>ReignBough</dc:creator>
      <dc:date>2023-07-12T19:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: API_BuildingMaterialType-&gt;id crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-API-BuildingMaterialType-gt-id-crashes/m-p/294412#M5038</link>
      <description>The solution for this is to pass a pointer to a valid GS::UniString variable in the ‘id’ field:&lt;BR /&gt;

&lt;PRE&gt;GS::UniString attrId;
ACAPI_Attribute attr;
 
BNZeroMemory (&amp;amp;attr, sizeof (attr));
attr.header.typeID = API_BuildingMaterialID;
attr.header.index = ….;
 
attr.buildingMaterial.id = &amp;amp;attrId;
if (ACAPI_Attribute_Get (&amp;amp;attr) == NoError)
{
  //... code here ...
}&lt;/PRE&gt;

This works similarly for ‘manufacturer’ and ‘description’.</description>
      <pubDate>Fri, 01 Jul 2016 02:42:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/SOLVED-API-BuildingMaterialType-gt-id-crashes/m-p/294412#M5038</guid>
      <dc:creator>ReignBough</dc:creator>
      <dc:date>2016-07-01T02:42:14Z</dc:date>
    </item>
  </channel>
</rss>

