2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations
2021-01-17
10:51 PM
- last edited on
2021-09-14
01:34 PM
by
Noemi Balogh
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.
Solved! Go to Solution.
2021-01-18 11:22 PM
2021-01-18 11:22 PM