<?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: AC crashes in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164069#M6276</link>
    <description>Well, I guess that its because im not used to this platform.&lt;BR /&gt;
I actually used the BNZeroMemory function because I saw that the example scripts use it, and I even tried to understand what it means, but it didnt work well. do u have any idea how to explain me that in a simpler way?&lt;BR /&gt;
And I didnt really catch what u meant in par 4.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for ur attention!</description>
    <pubDate>Sat, 27 Aug 2011 14:54:56 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2011-08-27T14:54:56Z</dc:date>
    <item>
      <title>AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164067#M6274</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello, &lt;BR /&gt;Im trying to develop something, and first of all need to access floor id.&lt;BR /&gt;I tried this code:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;	API_WorkspaceInfo	workspaceInfo;
	API_StoryInfo		storyInfo;
	API_ProjectInfo		projectInfo;
	GSErrCode			err;
	Int32				 ind;
	err = ACAPI_Environment (APIEnv_ProjectID, &amp;amp;projectInfo, NULL);
	err = ACAPI_Environment (APIEnv_UserWorkspaceID, &amp;amp;workspaceInfo, &amp;amp;projectInfo.userId);
	BNZeroMemory (&amp;amp;storyInfo, sizeof (API_StoryInfo));
	ACAPI_Environment (APIEnv_GetStorySettingsID, &amp;amp;storyInfo, NULL);
	ind = (*workspaceInfo.stories)&lt;I&gt;;
	
	//ACAPI_WriteReport("", );
	
	ACAPI_WriteReport( " "+(*storyInfo.data)[storyInfo.firstStory].floorId, true);
&lt;/I&gt;&lt;/PRE&gt;
When I run the built add-on, through AC, the program crushes (bug report).&lt;BR /&gt;&lt;BR /&gt;What am I doing wrong?&lt;BR /&gt;Is there another way to access this kind of information? (story information)&lt;BR /&gt;&lt;BR /&gt;Thanks a lot!&lt;/DIV&gt;</description>
      <pubDate>Thu, 03 Aug 2023 07:41:35 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164067#M6274</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-08-03T07:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164068#M6275</link>
      <description>&lt;BLOCKQUOTE&gt;zanzibar wrote:&lt;BR /&gt;Hello, &lt;BR /&gt;
Im trying to develop something, and first of all need to access floor id.&lt;BR /&gt;
I tried this code: ...etc... When I run the built add-on, through AC, the program crushes (bug report).&lt;BR /&gt;
Is there another way to access this kind of information? (story information)&lt;/BLOCKQUOTE&gt;
I've answered your question about retrieving storey information in another post. Just a few comments about your code:&lt;UL&gt;&lt;LI&gt;1. You should &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;always&lt;E&gt;&lt;/E&gt; zero out all structures before using them with API functions. You did this for &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;storeyInfo&lt;E&gt;&lt;/E&gt;, but not &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;projectInfo&lt;E&gt;&lt;/E&gt; or &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;workspaceInfo&lt;E&gt;&lt;/E&gt;.&lt;BR /&gt;
&lt;BR /&gt;
2. You aren't checking the error code returned by these function calls. If any of them fail, you should not expect the returned values to be valid or meaningful.&lt;BR /&gt;
&lt;BR /&gt;
3. What are you expecting the addition operator to do in the first parameter passed to ACAPI_WriteReport? Do you realise that the expression " " is a const char*, i.e. a pointer, and that adding an integer will result in a pointer to a non-specific memory address?&lt;BR /&gt;
&lt;BR /&gt;
4. Where did the variable &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;i&lt;E&gt;&lt;/E&gt; come from (line 10)? Is this a sensible subscript value?&lt;BR /&gt;
&lt;BR /&gt;
5. Don't forget to release any memory allocated by these functions, e.g. the storey array returned by &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;APIEnv_GetStorySettingsID&lt;E&gt;&lt;/E&gt;. Otherwise, you will suffer serious memory leaks.&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Sat, 27 Aug 2011 14:47:36 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164068#M6275</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2011-08-27T14:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164069#M6276</link>
      <description>Well, I guess that its because im not used to this platform.&lt;BR /&gt;
I actually used the BNZeroMemory function because I saw that the example scripts use it, and I even tried to understand what it means, but it didnt work well. do u have any idea how to explain me that in a simpler way?&lt;BR /&gt;
And I didnt really catch what u meant in par 4.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for ur attention!</description>
      <pubDate>Sat, 27 Aug 2011 14:54:56 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164069#M6276</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-27T14:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164070#M6277</link>
      <description>&lt;BLOCKQUOTE&gt;zanzibar wrote:&lt;BR /&gt;Well, I guess that its because im not used to this platform.&lt;BR /&gt;
I actually used the BNZeroMemory function because I saw that the example scripts use it, and I even tried to understand what it means, but it didnt work well. do u have any idea how to explain me that in a simpler way?&lt;BR /&gt;
And I didnt really catch what u meant in par 4.&lt;BR /&gt;
Thanks for ur attention!&lt;/BLOCKQUOTE&gt;
I think you need to take a course in C/C++ (or study the subject). A C programmer would not expect to be able to write:&lt;PRE&gt;"1 + 1 = " + 2;&lt;/PRE&gt;That's something you might do with BASIC.&lt;BR /&gt;
&lt;BR /&gt;
Similarly, &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;BNZeroMemory&lt;E&gt;&lt;/E&gt; should be immediately familiar to you. It's basically the same as using &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;memset&lt;E&gt;&lt;/E&gt; to fill a block of memory with zero values.&lt;BR /&gt;
&lt;BR /&gt;
My 4th point was referring to the following line:&lt;PRE&gt;ind = (*workspaceInfo.stories)&lt;I&gt;;&lt;/I&gt;&lt;/PRE&gt;
Where does the subscript value &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;i&lt;E&gt;&lt;/E&gt; come from? Does its value fit within the array bounds?</description>
      <pubDate>Sat, 27 Aug 2011 15:20:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164070#M6277</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2011-08-27T15:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164071#M6278</link>
      <description>The "i" value comes from a loop that runs this function for each floor, I assumed that 0,1,2 and so on are floor indexes.</description>
      <pubDate>Sat, 27 Aug 2011 17:40:05 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164071#M6278</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-27T17:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164072#M6279</link>
      <description>&lt;BLOCKQUOTE&gt;zanzibar wrote:&lt;BR /&gt;The "i" value comes from a loop that runs this function for each floor, I assumed that 0,1,2 and so on are floor indexes.&lt;/BLOCKQUOTE&gt;
I assumed so, but it would have been very helpful if you had left the loop in your sample code. Loops and subscript variables are common sources of hanging/crashing problems. I'm also assuming your loop begins just after the call to &lt;I&gt;&lt;/I&gt;&lt;S&gt;&lt;I&gt;&lt;I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/S&gt;APIEnv_GetStorySettingsID&lt;E&gt;&lt;/E&gt;?</description>
      <pubDate>Sun, 28 Aug 2011 08:21:13 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164072#M6279</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2011-08-28T08:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: AC crashes</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164073#M6280</link>
      <description>Well, youv'e helped me a lot, thx!!! &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" style="display : inline;" /&gt;</description>
      <pubDate>Sun, 28 Aug 2011 13:02:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/AC-crashes/m-p/164073#M6280</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2011-08-28T13:02:10Z</dc:date>
    </item>
  </channel>
</rss>

