<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: APIAny_ChangeAParameterID in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261330#M2058</link>
    <description>APIAny_ChangeAParameterID changes the parameters value only in the API_GetParamsType object in the memory. It does not changes any element or libpart in the project directly.&lt;BR /&gt;
You have to do something with the changed params handle to notify any change after the operation.&lt;BR /&gt;

&lt;PRE&gt;{
	API_GetParamsType theParams = {};
	API_ParamOwnerType paramOwner = {};
	GS::uchar_t uStrBuffer[BUFFER_SIZE];

	paramOwner.typeID = API_ObjectID;
	paramOwner.libInd = libPartIndex;

	GSErrCode err = ACAPI_Goodies (APIAny_OpenParametersID, &amp;amp;paramOwner);
	err |= ACAPI_Goodies (APIAny_GetActParametersID, &amp;amp;theParams);
	if (err == NoError) {
		API_ChangeParamType changeParam = {};

		CHTruncate (paramName, changeParam.name, API_NameLen);
		GS::ucsncpy (uStrBuffer, newStrValue.ToUStr ().Get (), BUFFER_SIZE);
		changeParam.uStrValue = uStrBuffer;

		err = ACAPI_Goodies (APIAny_ChangeAParameterID, &amp;amp;changeParam);
		if (err == NoError) {
			// Do something with theParams.params
		}
	}

	ACAPI_DisposeAddParHdl (&amp;amp;theParams.params);
	ACAPI_Goodies (APIAny_CloseParametersID);
}&lt;/PRE&gt;

I'm here to help, but at first I have to know what's your purpose...&lt;BR /&gt;
Do you want to change the parameter value in a placed element instance of the library part? If the answer is yes, then use this code instead of the "// Do something with theParams.params" comment:
&lt;PRE&gt;API_ElementMemo memo = {};
memo.params = theParams.params;

API_Element	mask;
ACAPI_ELEMENT_MASK_CLEAR (mask);

API_Element	elem = {};
elem.header.guid = elemGuid;
ACAPI_Element_Get (&amp;amp;elem);

err = ACAPI_Element_Change (&amp;amp;elem, &amp;amp;mask, &amp;amp;memo, APIMemoMask_AddPars, true);&lt;/PRE&gt;

Or you would like to change the default value of the parameter in a library part? To achieve that, you have to overwrite the library part in the library.</description>
    <pubDate>Tue, 27 Apr 2021 21:02:12 GMT</pubDate>
    <dc:creator>Tibor Lorantfy</dc:creator>
    <dc:date>2021-04-27T21:02:12Z</dc:date>
    <item>
      <title>APIAny_ChangeAParameterID</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261329#M2057</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Need some help in changing a STRING parameter in a Library Part. I have looked at several examples and they all only show modifying a float parameter. The problem I'm having is getting the API_​ChangeParamType GS::uchar_t *uStrValue attribute to point to the change string. My code is below. I can not get the correct format for ucscpy below . Please help. I know that I do not fully understand the conversions in Archicad between, ASCII, utf-16 , UTF-8 &amp;amp; UniStings usage, but need some help getting over the hump and started??&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;// change params here
						GS::UniString newtxt("XXX");
						API_ChangeParamType chgParam;
						API_ParamOwnerType     paramOwner;
						API_GetParamsType    getParams;
						
						BNZeroMemory(&amp;amp;chgParam, sizeof(API_ChangeParamType));
						BNZeroMemory(&amp;amp;paramOwner, sizeof(API_ParamOwnerType));
						BNZeroMemory(&amp;amp;getParams, sizeof(API_GetParamsType));

						paramOwner.libInd = libIndex;
						paramOwner.typeID = API_ObjectID;      /* object element */
						paramOwner.guid = APINULLGuid;
						
						ACAPI_Goodies(APIAny_OpenParametersID, &amp;amp;paramOwner,nullptr);
						err = ACAPI_Goodies(APIAny_GetActParametersID, &amp;amp;getParams, nullptr);
						if(err == NoError){ 
						     chgParam.index = libIndex;
						     CHCopyC("txt", chgParam.name);

						     GS::ucscpy(chgParam.uStrValue.uStr, newtxt.ToUStr()); //exception here
                                                 /*
						 chgParam is incorrect -- getting message error "left of uStr must have       class/struct/union" - I have changed ucsscpy all different ways and can't get it right.
                                                    */
						      err = ACAPI_Goodies(APIAny_ChangeAParameterID, &amp;amp;chgParam,nullptr);
						}
						ACAPI_Goodies(APIAny_CloseParametersID,nullptr,nullptr);
							if (err)
								ACAPI_WriteReport("busted",true);&lt;/PRE&gt;
EDIT:: found the answer here -- viewtopic.php?f=23&amp;amp;t=68038 Thanks Tibor However, using above with correction - still can't get string parameter to change?? Add-On runs with no errors but no change now.&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Sep 2021 07:40:04 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261329#M2057</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-09-14T07:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: APIAny_ChangeAParameterID</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261330#M2058</link>
      <description>APIAny_ChangeAParameterID changes the parameters value only in the API_GetParamsType object in the memory. It does not changes any element or libpart in the project directly.&lt;BR /&gt;
You have to do something with the changed params handle to notify any change after the operation.&lt;BR /&gt;

&lt;PRE&gt;{
	API_GetParamsType theParams = {};
	API_ParamOwnerType paramOwner = {};
	GS::uchar_t uStrBuffer[BUFFER_SIZE];

	paramOwner.typeID = API_ObjectID;
	paramOwner.libInd = libPartIndex;

	GSErrCode err = ACAPI_Goodies (APIAny_OpenParametersID, &amp;amp;paramOwner);
	err |= ACAPI_Goodies (APIAny_GetActParametersID, &amp;amp;theParams);
	if (err == NoError) {
		API_ChangeParamType changeParam = {};

		CHTruncate (paramName, changeParam.name, API_NameLen);
		GS::ucsncpy (uStrBuffer, newStrValue.ToUStr ().Get (), BUFFER_SIZE);
		changeParam.uStrValue = uStrBuffer;

		err = ACAPI_Goodies (APIAny_ChangeAParameterID, &amp;amp;changeParam);
		if (err == NoError) {
			// Do something with theParams.params
		}
	}

	ACAPI_DisposeAddParHdl (&amp;amp;theParams.params);
	ACAPI_Goodies (APIAny_CloseParametersID);
}&lt;/PRE&gt;

I'm here to help, but at first I have to know what's your purpose...&lt;BR /&gt;
Do you want to change the parameter value in a placed element instance of the library part? If the answer is yes, then use this code instead of the "// Do something with theParams.params" comment:
&lt;PRE&gt;API_ElementMemo memo = {};
memo.params = theParams.params;

API_Element	mask;
ACAPI_ELEMENT_MASK_CLEAR (mask);

API_Element	elem = {};
elem.header.guid = elemGuid;
ACAPI_Element_Get (&amp;amp;elem);

err = ACAPI_Element_Change (&amp;amp;elem, &amp;amp;mask, &amp;amp;memo, APIMemoMask_AddPars, true);&lt;/PRE&gt;

Or you would like to change the default value of the parameter in a library part? To achieve that, you have to overwrite the library part in the library.</description>
      <pubDate>Tue, 27 Apr 2021 21:02:12 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261330#M2058</guid>
      <dc:creator>Tibor Lorantfy</dc:creator>
      <dc:date>2021-04-27T21:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: APIAny_ChangeAParameterID</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261331#M2059</link>
      <description>Thanks Tibor:&lt;BR /&gt;
&lt;BR /&gt;
I got it to work now. The confusion was basically that i did not understand how Archicad's API called  and created elements.&lt;BR /&gt;
&lt;BR /&gt;
I just wanted to insert a Library part with mostly the same defaults but to change some key parameters. i did not want change the defaults. Basically reusing a base Lib Part over and over to do different things depending on a few user input param changes from another function.&lt;BR /&gt;
&lt;BR /&gt;
I did not realize that i did not need to use Change_Parameters at all  (since the changes were only used for the current object)   but just change the Library part params directly in the element create function after I retrieved the params list with GetParameters for the utility Lib Part.&lt;BR /&gt;
&lt;BR /&gt;
Sorry for the trouble but your above input helps explain things better for me. I copied it  for future reference&lt;BR /&gt;
&lt;BR /&gt;
Thanks again..</description>
      <pubDate>Tue, 27 Apr 2021 22:13:48 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/APIAny-ChangeAParameterID/m-p/261331#M2059</guid>
      <dc:creator>poco2013</dc:creator>
      <dc:date>2021-04-27T22:13:48Z</dc:date>
    </item>
  </channel>
</rss>

