Learn to manage BIM workflows and create professional Archicad templates with the BIM Manager Program.
a week ago
- last edited
a week ago
by
Noemi Balogh
I'm Programing on ArchiCAD27/Windows10/VisualStudio2019C++
I Create Element (Object "3DText") by C++;
Why My Function Execute Memory Reak in ArchiCAD?
First Execute = OK
Second Execute = Memory Reak Execute!
GSErrCode Create3DText( API_Coord3D pos
, short floorInd
, API_AttributeIndex layer
, API_Guid& obj_guid
, char *ownUnID
, NiArchi::GlobInfo globInfo
) {
GSErrCode res = NOERROR;
API_LibPart libpart = {};
libpart.typeID = APILib_ObjectID;
strcpy(libpart.ownUnID, ownUnID);
//res = ACAPI_LibPart_Search(&libpart, false);
res = ACAPI_LibraryPart_Search(&libpart, false);
if (res == NOERROR) {
API_ParamOwnerType paramOwner = {};
API_GetParamsType getParams = {};
paramOwner.libInd = libpart.index;
paramOwner.type.typeID = API_ObjectID;
paramOwner.guid = APINULLGuid;
res = ACAPI_LibraryPart_OpenParameters(¶mOwner);
if (res == NOERROR) {
res = ACAPI_LibraryPart_GetActParameters(&getParams);
if (res == NOERROR) {
API_Element elem = {};
API_ElementMemo memo = {};
//Object初期値取得
elem.header.type.typeID = API_ObjectID;
res = ACAPI_Element_GetDefaults(&elem, &memo);
if (res == NOERROR) {
memo.params = getParams.params;
elem.object.libInd = libpart.index;
elem.object.xRatio = getParams.a;
elem.object.yRatio = getParams.b;
elem.object.pos.x = pos.x;
elem.object.pos.y = pos.y;
if (layer.ToInt32_Deprecated() >= 0) {
elem.header.layer = layer;
}
elem.header.floorInd = floorInd;
double z_btm = globInfo.GetFloorZpos(floorInd);
elem.object.level = pos.z - z_btm;
res = ACAPI_CallUndoableCommand(
GS::UniString("Create Object")
, [&]()->GSErrCode {
return(ACAPI_Element_Create(&elem, &memo));
});
if (res == NOERROR) {
//成功
obj_guid = elem.header.guid;
}
}//endif
ACAPI_DisposeElemMemoHdls(&memo);
}//endif
}//endif
//CLOSE
if (res == NOERROR) {
res = ACAPI_LibraryPart_CloseParameters();
}
}//endif(res)
if (res != NOERROR) {
//Error Display
}
return(res);
}
Solved! Go to Solution.
Monday
Have you debugged into this code to see which line triggers the fault?
Tuesday
Thank you.
memo.params = getParams.params;
To
ACAPI_DisposeAddParHdl(&memo.params);
memo.params = getParams.params;
res = ACAPI_LibraryPart_CloseParameters();
Monday
Have you debugged into this code to see which line triggers the fault?
Tuesday
Thank you.
memo.params = getParams.params;
To
ACAPI_DisposeAddParHdl(&memo.params);
memo.params = getParams.params;
res = ACAPI_LibraryPart_CloseParameters();