Archicad C++ API
About Archicad add-on development using the C++ API.

Save library item settings.

Anonymous
Not applicable
Hello
Help change and save library item settings.
I can change them for the required library element, it is not placed on the plan and not the default tool. From this element, the script GDL then has to get globals.
void ModifyGlobParameters (const API_Guid &guid , const UInt32 index ,
	const double &valD1 , const double &valD2 )
{	
	API_ParamOwnerType   paramOwner;	
	API_ChangeParamType  chgParam;		
	API_GetParamsType    getParams;		
	GSErrCode            err;			
		
	BNZeroMemory (&paramOwner, sizeof (API_ParamOwnerType));	BNZeroMemory (&getParams, sizeof (API_GetParamsType)); 
	paramOwner.libInd = index; // !!!! default parameters of a Library Part itself !!!!
	paramOwner.typeID = API_ObjectID;      
	
	err = ACAPI_Goodies (APIAny_OpenParametersID, &paramOwner, NULL);
	if (err == NoError) {
		BNZeroMemory (&chgParam, sizeof (API_ChangeParamType));
		err = ACAPI_Goodies (APIAny_GetActParametersID, &getParams, NULL); 
		if (err == NoError) {
			chgParam.index = 0; 
			CHCopyC ("Global_ALL_SUMM_K", chgParam.name); 
			chgParam.realValue =  valD1;
			err = ACAPI_Goodies (APIAny_ChangeAParameterID, &chgParam, NULL); 
			if (err == NoError)
				err = ACAPI_Goodies (APIAny_GetActParametersID, &getParams, NULL); 
			chgParam.index = 0; 
			CHCopyC ("Global_kSum", chgParam.name); 
			chgParam.realValue = valD2;
			err = ACAPI_Goodies (APIAny_ChangeAParameterID, &chgParam, NULL); 
			if (err == NoError)
				err = ACAPI_Goodies (APIAny_GetActParametersID, &getParams, NULL); 
		}
		ACAPI_Goodies (APIAny_CloseParametersID, NULL, NULL);
		WriteReport ("All OK 1: %lf	2: %lf", (*getParams.params)[2].value.real , (*getParams.params)[3].value.real );
	}	
	if (err == NoError) {
		
		API_Element     element; 
		API_Element		mask;
		API_ElementMemo      memo;
		BNZeroMemory (&element, sizeof (API_Element));
		BNZeroMemory (&memo, sizeof (API_ElementMemo));
		ACAPI_ELEMENT_MASK_CLEAR (mask); 
		guid;
		element.header.typeID = API_ObjectID; 
		err = ACAPI_Element_GetDefaults (&element, &memo);
		ACAPI_ELEMENT_MASK_CLEAR (mask); 
		ACAPI_ELEMENT_MASK_SET (mask, API_ObjectType, libInd);					       
                element.object.libInd = index; 
		memo.params = getParams.params;	
		 //err =ACAPI_Element_ChangeDefaults (&element, &memo, &mask);
		//err = ACAPI_Element_Change (&element, &mask, &memo, );
               // SAVE ??????? unplaced library item parameters, not default tools

	}
	ACAPI_DisposeAddParHdl (&getParams.params);
	return;
}//ModifyLibParameters (void)
7 REPLIES 7
Ralph Wessel
Mentor
Just to clarify, are you trying to change the parameters of a library part (in the library – not an element instance placed in the project)?
Ralph Wessel BArch
Anonymous
Not applicable
Yes. not an element instance placed in the project.
It seems to me that you need to change the values that are set when creating the library element. The task as a whole is to transfer the values from the API -> GDL Global (LIBRARYGLOBAL)-> Gdl Object
Ralph Wessel
Mentor
Sorry, I'm still confused about what you want to achieve. Can you describe the intended workflow?
Ralph Wessel BArch
Anonymous
Not applicable
From the API, you need to change the parameters of the biliotech element, this element will not be placed on the plan, and will not be the element of the tool by default.
http://archicadapi.graphisoft.com/documentation/api_paramovnertype
Library part default - so I get it, then change it, but I don’t know how to save

Then through the GDL, LIBRARYGLOBAL ("Get_Global", "Global_kSum", kSum) in the desired element.
Akos Somorjai
Graphisoft
Graphisoft
ufo_ru wrote:
From the API, you need to change the parameters of the biliotech element, this element will not be placed on the plan, and will not be the element of the tool by default.
http://archicadapi.graphisoft.com/documentation/api_paramovnertype
Library part default - so I get it, then change it, but I don’t know how to save

Then through the GDL, LIBRARYGLOBAL ("Get_Global", "Global_kSum", kSum) in the desired element.
So, then is it a library global that appears in the model view options?

Akos
Anonymous
Not applicable
Yes it is, in the first version of my addon there was a global library element whose parameters were changed through the parameters of the model view. And all this can be implemented without addon with pure GDL properties. But as it turned out, the use of model view parameters in the event that it is not a graphical display that depends on it, but quantitative measurements are not the best solution. It is difficult to track the parameters of the model view, especially in interactive catalogs. Therefore, I decided to develop a second version of the addon where the global element will be changed not through GDL, but through the API, especially since I still created a modal window for the addon parameters. As can be seen from the code, I found this global library element made a change in its parameters, but I can not save it.

In short, it is necessary to change the parameters of the global library element from the API, after which the GDL script of library elements considers them.
Anonymous
Not applicable
Ralph wrote:
Sorry, I'm still confused about what you want to achieve. Can you describe the intended workflow?

I apologize for the intrusiveness. But I found a similar topic that you had in mind?
What are some ways?
https://archicad-talk.graphisoft.com/viewtopic.php?f=23&t=44981&p=225195&hilit=global&sid=0793479d82...