License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
Archicad C++ API
About Archicad add-on development using the C++ API.

[BUG?] AC24: Drawing anchor point error when creating drawings

Erenford
Booster
Hello,

I've updated my addon from AC 23 to AC 24 and tested it and I noticed it doesn't apply the anchor point I passed (APIAnc_MM) on the element, it reverts back to APIAnc_LB after ACAPI_Element_Create.

Its the same code used, seems no code changes for element creation unlike room relation / dg struct.

I posted pictures on resulting drawings, if you notice AC24 drawings are on same coords but placed on LB node instead of MM node.

I thought hotfix was the issue but I've updated to AC 3022 INT FULL and it still occurs
1 REPLY 1
Erenford
Booster
I made a sample code and tested it on a new empty project, still doesn't work

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);
	}
}

6 btw is APIAnc_LB
it should be 4, which is APIAnc_MM