<?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 ACAPI_Element_Get crashes in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Get-crashes/m-p/152705#M6144</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hi,&lt;BR /&gt;I need to get rid of hotlinks created by my add-on, and I've found a nice example in the Element_Test code.&lt;BR /&gt;But for a mysterious reason, Archicad crashes when I call the ACAPI_Element_Get function...&lt;BR /&gt;Here's the code :
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	//Function's error code
	GSErrCode err = NULL;
	//Containing the hotlink
	API_Element element;

	GS::Array&amp;lt;API_Guid&amp;gt; nodeRefList;
	if (ACAPI_Database (APIDb_GetHotlinkNodesID, NULL, &amp;amp;nodeRefList) == NoError) 
	{
		for (UIndex iNode = 0; iNode &amp;lt; nodeRefList.GetSize (); iNode++) 
		{
			BNZeroMemory (&amp;amp;element, sizeof (API_Element));
			element.header.typeID = API_HotlinkID;
			element.header.guid = nodeRefList[iNode];
			ACAPI_OpenUndoableSession("Effacer module");

         //Below is the crashing sentence
			err = ACAPI_Element_Get(&amp;amp;element);

			ACAPI_Database(APIDb_DeleteHotlinkNodeID, &amp;amp;nodeRefList[iNode], NULL);
			ACAPI_CloseUndoableSession();
		}
	}&lt;/PRE&gt;
My first thought was that this function needed to be into an undoable session, but I still have the same issue...&lt;BR /&gt;And I can't check the generated GSErrCode because Archicad crashes as soon as the function appear (no matter if the function is checked by "try...catch" method. Archicad just close everything and shows a nice BugReporter window...).&lt;BR /&gt;Does anyone have a clue ?&lt;BR /&gt;&lt;BR /&gt;Thanks !&lt;/DIV&gt;</description>
    <pubDate>Thu, 03 Aug 2023 08:31:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-08-03T08:31:25Z</dc:date>
    <item>
      <title>ACAPI_Element_Get crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Get-crashes/m-p/152705#M6144</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hi,&lt;BR /&gt;I need to get rid of hotlinks created by my add-on, and I've found a nice example in the Element_Test code.&lt;BR /&gt;But for a mysterious reason, Archicad crashes when I call the ACAPI_Element_Get function...&lt;BR /&gt;Here's the code :
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	//Function's error code
	GSErrCode err = NULL;
	//Containing the hotlink
	API_Element element;

	GS::Array&amp;lt;API_Guid&amp;gt; nodeRefList;
	if (ACAPI_Database (APIDb_GetHotlinkNodesID, NULL, &amp;amp;nodeRefList) == NoError) 
	{
		for (UIndex iNode = 0; iNode &amp;lt; nodeRefList.GetSize (); iNode++) 
		{
			BNZeroMemory (&amp;amp;element, sizeof (API_Element));
			element.header.typeID = API_HotlinkID;
			element.header.guid = nodeRefList[iNode];
			ACAPI_OpenUndoableSession("Effacer module");

         //Below is the crashing sentence
			err = ACAPI_Element_Get(&amp;amp;element);

			ACAPI_Database(APIDb_DeleteHotlinkNodeID, &amp;amp;nodeRefList[iNode], NULL);
			ACAPI_CloseUndoableSession();
		}
	}&lt;/PRE&gt;
My first thought was that this function needed to be into an undoable session, but I still have the same issue...&lt;BR /&gt;And I can't check the generated GSErrCode because Archicad crashes as soon as the function appear (no matter if the function is checked by "try...catch" method. Archicad just close everything and shows a nice BugReporter window...).&lt;BR /&gt;Does anyone have a clue ?&lt;BR /&gt;&lt;BR /&gt;Thanks !&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2023 08:31:25 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Get-crashes/m-p/152705#M6144</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-03T08:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: ACAPI_Element_Get crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Get-crashes/m-p/152706#M6145</link>
      <description>I've got the same problem. But I am using &lt;C&gt;API_HotlinkNode&lt;/C&gt; instead of &lt;C&gt;API_Element&lt;/C&gt;. Here is my code:&lt;BR /&gt;

&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;GS::Array&amp;lt;API_Guid&amp;gt; nodeRefList;
API_HotlinkTypeID type = APIHotlink_Module;
GSErrCode err = ACAPI_Database(APIDb_GetHotlinkNodesID, &amp;amp;type, &amp;amp;nodeRefList);
DBPrintf("node count: %d", nodeRefList.GetSize());
if (err==NoError)
{
  UInt32 len = nodeRefList.GetSize();
  for (UInt32 i=0; i&amp;lt;len; ++i)
  {
    API_HotlinkNode hotlinkNode;
    BNZeroMemory(&amp;amp;hotlinkNode, sizeof(API_HotlinkNode));
    hotlinkNode.guid = nodeRefList&lt;I&gt;;
    hotlinkNode.type = type;
    err = ACAPI_Database(APIDb_GetHotlinkNodeID, &amp;amp;hotlinkNode, NULL);
    if (err==NoError)
    {
      //... do something ...//

      if (hotlinkNode.sourceLocation!=NULL)
        delete hotlinkNode.sourceLocation;
      if (hotlinkNode.userData.data!=NULL)
        BMKillPtr (&amp;amp;hotlinkNode.userData.data);
    }
    else
      return err;
  }
}
else
  return err;
&lt;/I&gt;&lt;/PRE&gt;

I simply print the data (&lt;C&gt;DBPrintf()&lt;/C&gt;) on a Debug Window (DebugView). The data was printed but still the function crashes on exit.&lt;BR /&gt;
&lt;BR /&gt;
Help anyone?</description>
      <pubDate>Tue, 09 Jul 2013 09:51:24 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/ACAPI-Element-Get-crashes/m-p/152706#M6145</guid>
      <dc:creator>ReignBough</dc:creator>
      <dc:date>2013-07-09T09:51:24Z</dc:date>
    </item>
  </channel>
</rss>

