The Global ARCHICAD Community

Stay informed. Get help. Share your knowledge.

Discussions about using GRAPHISOFT's tools (API DevKit) for independent software developers

Moderators: Barry Kelly, Karl Ottenstein, LaszloNagy, ejrolon, gkmethy, Tibor Lorántfy, rmasaki, MOREH Tamas, Akos Somorjai, Ed Brown, Mihály Palenik


I'm attempting to change the content of a text object, and can alter it successfully like so:
Code: Select all
GSErrCode JHP_TextToCase(JHP_Text_Case textCase)
	GSErrCode				err;
	API_Neig				**selNeigs;
	API_ElementMemo		memo;
	API_Element				element, mask;

	selNeigs = (API_Neig**)BMAllocateHandle(sizeof(API_Neig), ALLOCATE_CLEAR, 0);
	err = JHP_GetSelectionOrSelect_Mult(&selNeigs);

	UInt32 nSel = BMGetHandleSize((GSHandle)selNeigs) / sizeof(API_Neig);

	err = ACAPI_Element_Select(selNeigs, nSel, true);

	for (UInt32 i = 0; i < nSel; ++i) {

		BNZeroMemory(&element, sizeof(API_Element));
		BNZeroMemory(&memo, sizeof(API_ElementMemo));

		element.header.guid = (*selNeigs)[i].guid;

		element.header.typeID = Neig_To_ElemID((*selNeigs)[i].neigID);

		if (element.header.typeID != API_TextID) { continue; }

		if (!ACAPI_Element_Filter(element.header.guid, APIFilt_IsEditable))
			WriteReport_Alert("Object not editable");

		if (ACAPI_Element_Get(&element) != NoError) {  continue; }

		if (ACAPI_Element_GetMemo(element.header.guid, &memo, APIMemoMask_TextContent) != NoError) {  continue; }

		JHP_ModifyTextCase(textCase, &memo);
		err = ACAPI_Element_Change(&element, &mask, &memo, APIMemoMask_TextContent, true);



	return err;
This code was created following examples in the Element_Modify.cpp, but when I use this code to change the TextContent, the text object's scale becomes far smaller without altering the element.text.size or anything similar.

The function
Code: Select all
JHP_ModifyTextCase(textCase, &memo);
merely changes the textContent of the memo to upper or lowercase.

When the function is called on text that has Fixed State: Scale Independent(Paper Size) setting, the text does not change size. However, if the text is set to Fixed State: Scale with plan (Model Size), then the text reduces in size greatly. Currently, the text goes from 2 1/2" to 15/64" using the above code, when it seems nothing should resize it.

If I try to get the current text size using
Code: Select all
, it appears to report the size and if I set the element.text.size in the mask, it still sets the size to a number far lower than it currently is.

Is this a bug? does text scale have to be recalculated somehow every time the content alone is changed?

In none of the examples did I see this written any differently or bothering with scale.

Any information would be great,

Found the solution.

Turns out, you need to write the memo.Paragraph back into the element to keep the text the same scale, even if you are only altering the textContent.

So changing the APIMemoMask_TextContent being passed into the Get memo call as well as the ElementChange call fixes the issue if the mask instead includes the paragraph.
Code: Select all
UInt32 memoMask = 0;
memoMask |= APIMemoMask_TextContent;
memoMask |= APIMemoMask_Paragraph;