<?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 APIERR_BADINDEX error when creating element using GDL object library index in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596099#M9262</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm currently exploring on Archicad API and GDL.&lt;/P&gt;
&lt;P&gt;I'm trying to place/create GDL object from an imported library.&lt;/P&gt;
&lt;P&gt;I am using the sample add-on template here:&lt;BR /&gt;&lt;A href="https://github.com/GRAPHISOFT/archicad-addon-cmake" target="_blank" rel="noopener"&gt;https://github.com/GRAPHISOFT/archicad-addon-cmake&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I'm currently using Archicad 26.&amp;nbsp;&lt;BR /&gt;I imported a library with GDL (I just found online though its version is Archicad 29. But i can insert the object successfully in the ground floor)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kristkun_0-1711259892450.png" style="width: 644px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/57815i06B1E324DBBEDE8B/image-dimensions/644x192?v=v2" width="644" height="192" role="button" title="kristkun_0-1711259892450.png" alt="kristkun_0-1711259892450.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I modified the Add-on sample, to create a GDL object when the custom menu was clicked.&lt;BR /&gt;I did follow this topic but I'm having issues whit the&amp;nbsp;APIERR_BADINDEX error message when ACAPI_Element_Create() was called.&lt;BR /&gt;&lt;A href="https://community.graphisoft.com/t5/Archicad-C-API/How-to-call-and-place-a-GDL-element-with-API-functions/m-p/353781" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Archicad-C-API/How-to-call-and-place-a-GDL-element-with-API-functions/m-p/353781&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kristkun_0-1711260716496.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/57817i8ECB2C5DE80865CF/image-size/large?v=v2&amp;amp;px=999" role="button" title="kristkun_0-1711260716496.png" alt="kristkun_0-1711260716496.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;After Create, an error was raised&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kristkun_1-1711260835101.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/57818i9C644FD9451E2276/image-size/large?v=v2&amp;amp;px=999" role="button" title="kristkun_1-1711260835101.png" alt="kristkun_1-1711260835101.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, there is no error occurred when searching for the library part (I used the file name to search for the library index. I added a breakpoint before the create element is called)&lt;BR /&gt;&lt;BR /&gt;Hope someone could help me with this.&lt;BR /&gt;Regards&lt;/P&gt;</description>
    <pubDate>Mon, 16 Sep 2024 12:48:07 GMT</pubDate>
    <dc:creator>kristkun</dc:creator>
    <dc:date>2024-09-16T12:48:07Z</dc:date>
    <item>
      <title>APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596099#M9262</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I'm currently exploring on Archicad API and GDL.&lt;/P&gt;
&lt;P&gt;I'm trying to place/create GDL object from an imported library.&lt;/P&gt;
&lt;P&gt;I am using the sample add-on template here:&lt;BR /&gt;&lt;A href="https://github.com/GRAPHISOFT/archicad-addon-cmake" target="_blank" rel="noopener"&gt;https://github.com/GRAPHISOFT/archicad-addon-cmake&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I'm currently using Archicad 26.&amp;nbsp;&lt;BR /&gt;I imported a library with GDL (I just found online though its version is Archicad 29. But i can insert the object successfully in the ground floor)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kristkun_0-1711259892450.png" style="width: 644px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/57815i06B1E324DBBEDE8B/image-dimensions/644x192?v=v2" width="644" height="192" role="button" title="kristkun_0-1711259892450.png" alt="kristkun_0-1711259892450.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I modified the Add-on sample, to create a GDL object when the custom menu was clicked.&lt;BR /&gt;I did follow this topic but I'm having issues whit the&amp;nbsp;APIERR_BADINDEX error message when ACAPI_Element_Create() was called.&lt;BR /&gt;&lt;A href="https://community.graphisoft.com/t5/Archicad-C-API/How-to-call-and-place-a-GDL-element-with-API-functions/m-p/353781" target="_blank" rel="noopener"&gt;https://community.graphisoft.com/t5/Archicad-C-API/How-to-call-and-place-a-GDL-element-with-API-functions/m-p/353781&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kristkun_0-1711260716496.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/57817i8ECB2C5DE80865CF/image-size/large?v=v2&amp;amp;px=999" role="button" title="kristkun_0-1711260716496.png" alt="kristkun_0-1711260716496.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;After Create, an error was raised&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="kristkun_1-1711260835101.png" style="width: 999px;"&gt;&lt;img src="https://community.graphisoft.com/t5/image/serverpage/image-id/57818i9C644FD9451E2276/image-size/large?v=v2&amp;amp;px=999" role="button" title="kristkun_1-1711260835101.png" alt="kristkun_1-1711260835101.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you can see, there is no error occurred when searching for the library part (I used the file name to search for the library index. I added a breakpoint before the create element is called)&lt;BR /&gt;&lt;BR /&gt;Hope someone could help me with this.&lt;BR /&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 12:48:07 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596099#M9262</guid>
      <dc:creator>kristkun</dc:creator>
      <dc:date>2024-09-16T12:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596102#M9263</link>
      <description>&lt;P&gt;Just an additional info. I also tried adding the memo in the parameter (commented code) but the same error has been raised&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 06:23:44 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596102#M9263</guid>
      <dc:creator>kristkun</dc:creator>
      <dc:date>2024-03-24T06:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596103#M9264</link>
      <description>&lt;P&gt;I think you are missing&amp;nbsp;&lt;SPAN&gt;ACAPI_CallUndoableCommand() scope.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 07:07:38 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596103#M9264</guid>
      <dc:creator>Miha Nahtigal</dc:creator>
      <dc:date>2024-03-24T07:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596105#M9265</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I just tried adding this mentioned method but still raising the same error code.&lt;BR /&gt;(I'm hoping i did apply the method correctly though)&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;static GSErrCode MenuCommandHandler (const API_MenuParams *menuParams)
{
	switch (menuParams-&amp;gt;menuItemRef.menuResID) {
		case AddOnMenuID:
			switch (menuParams-&amp;gt;menuItemRef.itemIndex) {
				case AddOnCommandID:
					{
						/*ExampleDialog dialog;
						dialog.Invoke ();*/

						API_LibPart		m_libpart;
						BNZeroMemory(&amp;amp;m_libpart, sizeof(API_LibPart)); 
						m_libpart.typeID = APILib_ObjectID;
						const GS::UniString fileName { "05 Basic 2D example 1 AC19.gsm" };
						GS::ucscpy(m_libpart.file_UName, fileName.ToUStr());
						GSErrCode m_err = ACAPI_LibPart_Search(&amp;amp;m_libpart, false, true);

						Int32 m_ParamsCount = 0;
						double a, b;
						API_AddParType** params = NULL;
						m_err = ACAPI_LibPart_GetParams(m_libpart.index, &amp;amp;a, &amp;amp;b, &amp;amp;m_ParamsCount, &amp;amp;params);

						API_Element	m_element ;
						BNZeroMemory(&amp;amp;m_element, sizeof(API_Element));
						// GDL Object type
						m_element.header.type.typeID = API_ObjectID;
						// Library index
						m_element.object.libInd = m_libpart.index;
						
						API_ElementMemo m_memo;
						BNZeroMemory(&amp;amp;m_memo, sizeof(API_ElementMemo));
						m_memo.params = params;
						

						m_err = ACAPI_CallUndoableCommand("Create GDL Element", [&amp;amp;]() -&amp;gt; GSErrCode {
							return ACAPI_Element_Create(&amp;amp;m_element, &amp;amp;m_memo);
						});
						if (m_err != NoError) {
							return m_err;
						}
					}
					break;
			}
			break;
	}
	return NoError;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 24 Mar 2024 14:18:29 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/596105#M9265</guid>
      <dc:creator>kristkun</dc:creator>
      <dc:date>2024-03-24T14:18:29Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637189#M9921</link>
      <description>&lt;P&gt;HI! I'm having the same issue. Did someone found the root cause for this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 14:30:40 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637189#M9921</guid>
      <dc:creator>zaza95</dc:creator>
      <dc:date>2024-10-25T14:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637350#M9922</link>
      <description>&lt;P&gt;Hi, I'd suggest you to check whether the value of&amp;nbsp;&lt;SPAN&gt;element&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;header&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;layer is correct, it shouldn't be zero.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;HTH.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 05:26:11 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637350#M9922</guid>
      <dc:creator>Hiromichi Shinkawa</dc:creator>
      <dc:date>2024-10-28T05:26:11Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637413#M9923</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have set the layer to 1, but I'm still facing the issue. Do you any other idea on the reason?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2024 12:49:10 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637413#M9923</guid>
      <dc:creator>zaza95</dc:creator>
      <dc:date>2024-10-28T12:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error when creating element using GDL object library index</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637541#M9924</link>
      <description>&lt;P&gt;Hi, then please add one command before you set the library index like below.&lt;/P&gt;
&lt;P&gt;HTH.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;API_Element	m_element;
BNZeroMemory(&amp;amp;m_element, sizeof(API_Element));
// GDL Object type
m_element.header.type.typeID = API_ObjectID;

m_err = ACAPI_Element_GetDefaults (&amp;amp;m_element, NULL);

// Library index
m_element.object.libInd = m_libpart.index;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2024 01:48:33 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-when-creating-element-using-GDL-object/m-p/637541#M9924</guid>
      <dc:creator>Hiromichi Shinkawa</dc:creator>
      <dc:date>2024-10-29T01:48:33Z</dc:date>
    </item>
  </channel>
</rss>

