ACAPI_Element_Create (& columnElem, & columnMemo); An error has occurred during debugging.
What's wrong?
---------------------------------------------------------------------------------------------------------------------------------------------
GSErrCode err;
GS::Array<API_Guid> polylineList, textList;
err = ACAPI_Element_GetElemList(API_PolyLineID, &polylineList);
WriteReport("Number of total polyline: %u", (GS::UIntForStdio) polylineList.GetSize());
err = ACAPI_Element_GetElemList(API_TextID, &textList);
WriteReport("Number of total Text: %u", (GS::UIntForStdio) textList.GetSize());
Int32 i,j;
API_Element polyElem, textElem, columnElem;
API_ElementMemo polyMemo, textMemo, columnMemo;
API_Coord cenCoord;
API_Guid guid;
char text[20];
double a, b,x,y,minDist,Dist;
for (i = 0 ; i < 1; i++) //polylineList.GetSize(); i++)
{
BNZeroMemory(&polyElem, sizeof(API_Element));
BNZeroMemory(&polyMemo, sizeof(API_ElementMemo));
polyElem.header.guid = polylineList;
err = ACAPI_Element_Get(&polyElem);
err = ACAPI_Element_GetMemo(polyElem.header.guid, &polyMemo);
b = DistCPtr(&(*polyMemo.coords)[1], &(*polyMemo.coords)[2]);
a = DistCPtr(&(*polyMemo.coords)[2], &(*polyMemo.coords)[3]);
cenCoord.x = ((*polyMemo.coords)[1].x + (*polyMemo.coords)[2].x + (*polyMemo.coords)[3].x + (*polyMemo.coords)[4].x) / 4;
cenCoord.y = ((*polyMemo.coords)[1].y + (*polyMemo.coords)[2].y + (*polyMemo.coords)[3].y + (*polyMemo.coords)[4].y) / 4;
minDist = 100000000000000;
for (j=0 ; j<textList.GetSize(); j++)
{
BNZeroMemory(&textElem, sizeof(API_Element));
BNZeroMemory(&textMemo, sizeof(API_ElementMemo));
textElem.header.guid = textList;
err = ACAPI_Element_Get(&textElem);
err = ACAPI_Element_GetMemo(textElem.header.guid, &textMemo);
Dist = DistCPtr(&textElem.text.loc, &cenCoord);
if (Dist < minDist)
{
minDist = Dist;
strcpy(text, *textMemo.textContent);
guid = textElem.header.guid;
}
}
BNZeroMemory(&columnElem, sizeof(API_Element));
BNZeroMemory(&columnMemo, sizeof(API_ElementMemo));
columnElem.header.typeID = API_ColumnID;
GSErrCode err = ACAPI_Element_GetDefaults(&columnElem, nullptr);
columnElem.column.coreWidth = a;
columnElem.column.coreDepth = b;
columnElem.column.origoPos = cenCoord;
columnMemo.coords = (API_Coord**)BMhAllClear((5) * sizeof(API_Coord));
columnMemo.elemInfoString = new GS::UniString(text);
GS::UniString *elemInfoString= columnMemo.elemInfoString;
(*columnMemo.coords)[1].x = (*polyMemo.coords)[1].x;
(*columnMemo.coords)[1].y = (*polyMemo.coords)[1].y;
(*columnMemo.coords)[2].x = (*polyMemo.coords)[2].x;
(*columnMemo.coords)[2].y = (*polyMemo.coords)[2].y;
(*columnMemo.coords)[3].x = (*polyMemo.coords)[3].x;
(*columnMemo.coords)[3].y = (*polyMemo.coords)[3].y;
(*columnMemo.coords)[4].x = (*polyMemo.coords)[4].x;
(*columnMemo.coords)[4].y = (*polyMemo.coords)[4].y;
(*columnMemo.coords)[5].x = (*polyMemo.coords)[5].x;
(*columnMemo.coords)[5].y = (*polyMemo.coords)[5].y;
err = ACAPI_Element_Create(&columnElem, &columnMemo); // nullptr);// ==> Error
}
ACAPI_DisposeElemMemoHdls(&polyMemo);
ACAPI_DisposeElemMemoHdls(&textMemo);
ACAPI_DisposeElemMemoHdls(&columnMemo);