<?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: APIERR_BADINDEX error on ACAPI_Element_Create in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-on-ACAPI-Element-Create/m-p/237653#M3002</link>
    <description>found the error ... bad cube UnID    &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_eek.gif" style="display : inline;" /&gt;</description>
    <pubDate>Mon, 18 Jan 2021 22:22:59 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-01-18T22:22:59Z</dc:date>
    <item>
      <title>APIERR_BADINDEX error on ACAPI_Element_Create</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-on-ACAPI-Element-Create/m-p/237652#M3001</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello,&lt;BR /&gt;could anyone help a newbie?&lt;BR /&gt;I got APIERR_BADINDEX error on ACAPI_Element_Create and I can't get out.&lt;BR /&gt;This is the function code:
&lt;PRE&gt;GSErrCode CreateObjectElement (double posX, double posY, API_Guid&amp;amp; placedObjectGuid)
{
    GSErrCode err = NoError;
    API_Element objElement = {};
    API_ElementMemo  memo = {};

    BNZeroMemory (&amp;amp;objElement, sizeof (API_Element));
    BNZeroMemory (&amp;amp;memo, sizeof (API_ElementMemo));

    API_LibPart libPart;
    BNZeroMemory (&amp;amp;libPart, sizeof (API_LibPart));
    libPart.typeID = APILib_ObjectID;
    libPart.isTemplate = false;
    libPart.isPlaceable = true;
    CHCopyC ("{9C72BC5B-9742-4B29-8863-75AAF5F23226}-{4281AA33-3CD6-46A2-AAB0-85F555577C6F}", libPart.ownUnID); // Cube unID

    // searching the libray using "libPart.ownUnID"
    err = ACAPI_LibPart_Search(&amp;amp;libPart, false);
    if (err != NoError) {
        return err;
    }
    
    objElement.object.libInd=libPart.index; //library index
    objElement.object.head.typeID = API_ObjectID;
    objElement.object.head.variationID = APIVarId_Object;
    err = ACAPI_Element_GetDefaults (&amp;amp;objElement, &amp;amp;memo);
    if (err != NoError) {
        return err;
    }

    double aParam, bParam;
    Int32 addParNum;
    
    err = ACAPI_LibPart_GetParams (libPart.index, &amp;amp;aParam, &amp;amp;bParam, &amp;amp;addParNum, &amp;amp;memo.params);
    if(err != noErr){
        return err;
    }

    objElement.object.libInd=libPart.index;
    objElement.object.head.typeID = API_ObjectID;
    objElement.object.head.variationID = APIVarId_Object;
    objElement.object.pos.x = 0;
    objElement.object.pos.y = 0;
    objElement.object.level = 0;
    
    err = ACAPI_Element_Create (&amp;amp;objElement, &amp;amp;memo);
    if (err != NoError) {
        return err; // ------- got error here!! ------
    }

    placedObjectGuid = objElement.header.guid;
    ACAPI_DisposeElemMemoHdls (&amp;amp;memo);
    return NoError;
}
&lt;/PRE&gt;
The function is called from a ACAPI_CallUndoableCommand block:
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;                ACAPI_CallUndoableCommand ("Create and Object", [&amp;amp;] () -&amp;gt; GSErrCode {
                    err = STR_OM::CreateObjectElement (columnElement.column.origoPos.x  + 1, columnElement.column.origoPos.y + 1, placedObjectGuid);
                    if (err != NoError)
                        return err;
                     ...
                    return NoError;
                });
&lt;/PRE&gt;
Thanks in advance.&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 11:34:57 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-on-ACAPI-Element-Create/m-p/237652#M3001</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-14T11:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: APIERR_BADINDEX error on ACAPI_Element_Create</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-on-ACAPI-Element-Create/m-p/237653#M3002</link>
      <description>found the error ... bad cube UnID    &lt;IMG src="https://community.graphisoft.com/legacyfs/online/emojis/icon_eek.gif" style="display : inline;" /&gt;</description>
      <pubDate>Mon, 18 Jan 2021 22:22:59 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIERR-BADINDEX-error-on-ACAPI-Element-Create/m-p/237653#M3002</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-18T22:22:59Z</dc:date>
    </item>
  </channel>
</rss>

