We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2007-12-12 10:03 AM - last edited on 2023-08-04 04:13 PM by Doreena Deng
XFORM 1, cos(alfa), 0, 0, 0, 1, 0, 0, 0, 0, 1, 0 BLOCK A, B, 1
IO::Location rab("D:/GDLobjects/"); if(!rab.IsValid()) throw ElementException("bad location"); if(ACAPI_Environment (APIEnv_AddLibrariesID, reinterpret_cast<void *>(&rab), NULL) == NoError) _interface->GetReporter().Report("folder added"); else throw ElementException("registering location failed");
API_LibPart part; GSErrCode err; BNZeroMemory(&part, sizeof(API_LibPart)); CHANSI2Unicode("box.gsm", strlen("box.gsm"), part.file_UName, API_UniLongNameLen); if((err = ACAPI_LibPart_Search(&part, false)) == NoError) { if((err = ACAPI_LibPart_Get(&part)) == NoError) { // place on specified location } else _interface->GetReporter().Report(err); } else _interface->GetReporter().Report(err);
2007-12-12 03:27 PM
bamboos wrote:You've looked up the definition of a library part, but now you want to place an instance of it. They are completely different things.
I haven't found any function in ACAPI_LibPart_* to place it on scene and pass parameters to it (like: A, B, alfa);
2007-12-12 05:44 PM
API_Element element; API_ElementMemo memo; BNZeroMemory(&element, sizeof(API_Element)); BNZeroMemory(&memo, sizeof(API_ElementMemo)); double A = 0; double B = 0; long parCount = 0; //---- element.header.typeID = API_ObjectID; ACAPI_Element_GetDefaults(&element, &memo); ACAPI_LibPart_GetParams(part.index, &A, &B, &parCount, &memo.params); element.object.angle = 0; element.object.pos.x = 0 + i; element.object.pos.y = 0 + ii; element.object.xRatio = A; element.object.yRatio = B; element.object.libInd = part.index; ACAPI_Element_Create(&element, &memo);