2021-01-05 10:22 AM - last edited on 2021-09-14 01:35 PM by Noemi Balogh
2021-01-07 06:48 AM
void Test_CreateDrawing() { API_NavigatorItem item; // Gets view with id "TEST" and name "TEST" TEST_Navigator(item); API_Element elem; BNZeroMemory(&elem, sizeof(elem)); elem.drawing.head.typeID = API_DrawingID; GSErrCode err = ACAPI_Element_GetDefaults(&elem, NULL); elem.header.layer = ARCHICAD_LAYER; //set to Archicad Layer elem.drawing.drawingGuid = item.guid; elem.drawing.isCutWithFrame = true; elem.drawing.ratio = 1; elem.drawing.angle = 0; elem.drawing.colorMode = APIColorMode_OriginalColors; elem.drawing.penTableUsageMode = APIPenTableUsageMode_UseOwnPenTable; elem.drawing.useOwnOrigoAsAnchor = false; elem.drawing.manualUpdate = false; // set name elem.drawing.nameType = APIName_CustomName; sprintf(elem.drawing.name, "TEST"); // coords (hotspot pos) elem.drawing.pos.x = 0.427592; elem.drawing.pos.y = 0.271358; // set anchor point to middle node // ~~ MAIN ISSUE: this is not applied and reverts to APIAnc_LB ~~ elem.drawing.anchorPoint = APIAnc_MM; // Create drawing ACAPI_CallUndoableCommand("Create Layout Drawing", [&] () -> GSErrCode { // err = ACAPI_Element_Create(&elem, NULL); return NoError; }); if (err != NoError) { WriteReport("[" __FUNC__ "] ERROR %s - ACAPI_Element_Create", ErrId2Name(err)); return; } // get drawing to check value if (ACAPI_Element_Get(&elem) == NoError) { // prints out anchor point, prints 6 (LB) not 4 (MM) WriteReport("elem.drawing.anchorPoint: %d", elem.drawing.anchorPoint); // Try to change anchor point again API_Element mask; ACAPI_ELEMENT_MASK_CLEAR(mask); ACAPI_ELEMENT_MASK_SET(mask, API_DrawingType, anchorPoint); elem.drawing.anchorPoint = APIAnc_MM; ACAPI_CallUndoableCommand("Update Drawing", [&]() -> GSErrCode { // err = ACAPI_Element_Change(&elem, &mask, NULL, NULL, true); return NoError; }); if (err != NoError) { WriteReport("[" __FUNC__ "] ERROR %s - ACAPI_Element_Change", ErrId2Name(err)); return; } // get drawing for the 2nd time then print anchor, still prints 6 if (ACAPI_Element_Get(&elem) == NoError) WriteReport("elem.drawing.anchorPoint: %d", elem.drawing.anchorPoint); } }