cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

How to change the value of a label linked to a fixed named optional parameter in the API

arad
Contributor

I’m trying to modify parameters when creating a label.
How can I change the value of a symbol label that is linked to a fixed named optional parameter?
Changing it from the API_LabelType or by modifying the object parameters does not produce the expected result.

 

arad_0-1760690596972.png

 

 

GSErrCode SetLabel(API_Element* elem, const GS::UniString& libpartName) {
	GSErrCode err = NoError;

	API_LibPart libpart = {};
	BNZeroMemory(&libpart, sizeof(API_LibPart));

	GS::ucscpy(libpart.docu_UName, libpartName.ToUStr());
	err = ACAPI_LibraryPart_Search(&libpart, false);

	API_ParamOwnerType   paramOwner = {};
	API_ChangeParamType  chgParam = {};
	API_GetParamsType getParams = {};

	paramOwner.libInd = libpart.index;
	err = ACAPI_LibraryPart_OpenParameters(&paramOwner);

	if (err == NoError) {
		err = ACAPI_LibraryPart_GetActParameters(&getParams);

		if (err == NoError) {
			CHCopyC("iReferencePoint", chgParam.name);
			chgParam.realValue = 5;
			err = ACAPI_LibraryPart_ChangeAParameter(&chgParam); //can change parameter

			CHCopyC("AC_TextAlignment_1", chgParam.name);
			chgParam.realValue = 2;
			err = ACAPI_LibraryPart_ChangeAParameter(&chgParam); //cannot change parameter

			if (err == NoError)
				err = ACAPI_LibraryPart_GetActParameters(&getParams);
		}
		ACAPI_LibraryPart_CloseParameters();
	}

	API_Element     label = {};
	API_ElementMemo labelMemo = {};
	BNZeroMemory(&labelMemo, sizeof(API_ElementMemo));

	label.header.type.typeID = API_LabelID;
	label.label.parentType = elem->header.type.typeID;

	err = ACAPI_Element_GetDefaults(&label, &labelMemo);

	TurnAutoTextFlagOff(); //This function is defined externally.

	labelMemo.params = getParams.params;

	label.label.labelClass = APILblClass_Symbol;
	label.label.parent = elem->header.guid;
	label.label.u.symbol.libInd = libpart.index;
	label.label.u.symbol.ownerType.typeID = elem->header.type.typeID;

	label.label.u.text.pen = 36;
	label.label.framed = false;
	label.label.textWay = APIDir_Parallel;
	label.label.textSize = 2.6;
	label.label.hasLeaderLine = false;
	label.label.pen = 36;
	label.label.arrowData.arrowPen = 36;
	label.label.framed = false;
	label.label.createAtDefaultPosition = true;
	label.label.u.text.just = APIJust_Center; //not work

	err = ACAPI_Element_Create(&label, &labelMemo);

	ACAPI_DisposeElemMemoHdls(&labelMemo);

	return err;
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Akos Somorjai
Graphisoft
Graphisoft

Hi Arad,

 

AC_ parameters cannot be changed from the API, as they are controlled directly from Archicad (see the GDL reference guide, section "Parameters for Text Handling").

It seems that the API currently ignores the text settings when you create a symbol label. So, my idea is to set the default parameters for a text label (including justification), then create the symbol label. (and set the defaults back if needed)

 

Best, Akos

View solution in original post

2 REPLIES 2
Solution
Akos Somorjai
Graphisoft
Graphisoft

Hi Arad,

 

AC_ parameters cannot be changed from the API, as they are controlled directly from Archicad (see the GDL reference guide, section "Parameters for Text Handling").

It seems that the API currently ignores the text settings when you create a symbol label. So, my idea is to set the default parameters for a text label (including justification), then create the symbol label. (and set the defaults back if needed)

 

Best, Akos

arad
Contributor

Changing the default label settings first worked well.
Thank you very much, Akos.