Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

APIERR_BADINDEX error on ACAPI_Element_Create

Anonymous
Not applicable
Hello,
could anyone help a newbie?
I got APIERR_BADINDEX error on ACAPI_Element_Create and I can't get out.
This is the function code:
GSErrCode CreateObjectElement (double posX, double posY, API_Guid& placedObjectGuid)
{
    GSErrCode err = NoError;
    API_Element objElement = {};
    API_ElementMemo  memo = {};

    BNZeroMemory (&objElement, sizeof (API_Element));
    BNZeroMemory (&memo, sizeof (API_ElementMemo));

    API_LibPart libPart;
    BNZeroMemory (&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(&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 (&objElement, &memo);
    if (err != NoError) {
        return err;
    }

    double aParam, bParam;
    Int32 addParNum;
    
    err = ACAPI_LibPart_GetParams (libPart.index, &aParam, &bParam, &addParNum, &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 (&objElement, &memo);
    if (err != NoError) {
        return err; // ------- got error here!! ------
    }

    placedObjectGuid = objElement.header.guid;
    ACAPI_DisposeElemMemoHdls (&memo);
    return NoError;
}
The function is called from a ACAPI_CallUndoableCommand block:

                ACAPI_CallUndoableCommand ("Create and Object", [&] () -> GSErrCode {
                    err = STR_OM::CreateObjectElement (columnElement.column.origoPos.x  + 1, columnElement.column.origoPos.y + 1, placedObjectGuid);
                    if (err != NoError)
                        return err;
                     ...
                    return NoError;
                });
Thanks in advance.
1 ACCEPTED SOLUTION

Solution
Anonymous
Not applicable
found the error ... bad cube UnID

View solution in original post

1 REPLY 1

Solution
Anonymous
Not applicable
found the error ... bad cube UnID

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!