We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2021-04-21 08:31 PM - last edited on 2021-09-14 09:40 AM by Noemi Balogh
// change params here GS::UniString newtxt("XXX"); API_ChangeParamType chgParam; API_ParamOwnerType paramOwner; API_GetParamsType getParams; BNZeroMemory(&chgParam, sizeof(API_ChangeParamType)); BNZeroMemory(¶mOwner, sizeof(API_ParamOwnerType)); BNZeroMemory(&getParams, sizeof(API_GetParamsType)); paramOwner.libInd = libIndex; paramOwner.typeID = API_ObjectID; /* object element */ paramOwner.guid = APINULLGuid; ACAPI_Goodies(APIAny_OpenParametersID, ¶mOwner,nullptr); err = ACAPI_Goodies(APIAny_GetActParametersID, &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, &chgParam,nullptr); } ACAPI_Goodies(APIAny_CloseParametersID,nullptr,nullptr); if (err) ACAPI_WriteReport("busted",true);EDIT:: found the answer here -- viewtopic.php?f=23&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.
Solved! Go to Solution.
2021-04-27 11:02 PM
{ 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, ¶mOwner); err |= ACAPI_Goodies (APIAny_GetActParametersID, &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, &changeParam); if (err == NoError) { // Do something with theParams.params } } ACAPI_DisposeAddParHdl (&theParams.params); ACAPI_Goodies (APIAny_CloseParametersID); }I'm here to help, but at first I have to know what's your purpose...
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 (&elem); err = ACAPI_Element_Change (&elem, &mask, &memo, APIMemoMask_AddPars, true);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.
2021-04-27 11:02 PM
{ 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, ¶mOwner); err |= ACAPI_Goodies (APIAny_GetActParametersID, &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, &changeParam); if (err == NoError) { // Do something with theParams.params } } ACAPI_DisposeAddParHdl (&theParams.params); ACAPI_Goodies (APIAny_CloseParametersID); }I'm here to help, but at first I have to know what's your purpose...
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 (&elem); err = ACAPI_Element_Change (&elem, &mask, &memo, APIMemoMask_AddPars, true);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.
2021-04-28 12:13 AM