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

ACAPI_Element_RefreshElement() doesn't work on AC27

HKM
Contributor

blnForce = true;
err = ACAPI_Element_RefreshElement( &element.header, &blnForce);
//It worked on AC26 but not on AC27
//Please tell me how to deal with it

//note)element is GDL with script

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

My understanding is that this solution is not a workaround. You shouldn't need an extra parameter script call when you place an element.

 

Looking at the source code, the function internally calls the parameter script with your parametrization, so I don't know what else to fix. Do you receive any errors?

 

Best, Akos

View solution in original post

10 REPLIES 10
HKM
Contributor

Additional notes)
If replaced with 'ACAPI_Element_SetElementURLRef()' one step above in ACAPI_Database.h, no error will occur.

HKM
Contributor

I forgot to mention something important.
It's a windows version.
API Development Kit 27.3001

LChen
Graphisoft
Graphisoft

Hi,

Please update your AC27 to the latest version (27.2.1) and check it again.

 

HTH

Archicad27 updated to version 27.2.1.
The error no longer occurs when calling up the function, but it is no longer functioning.

//bool force = true;
//err = ACAPI_Element_RefreshElement( &element.header, &force);

force = true : rebuild for GDL based elements (run parameter script).
is not work.

The process to 'ACAPI_Element_RefreshElement'
 
API_Element element;
API_ElementMemo memo;
BNZeroMemory(&element, sizeof(API_Element));
BNZeroMemory(&memo, sizeof(API_ElementMemo));

element.header.type.typeID = API_ObjectID;
err = ACAPI_Element_GetDefaults(&element, &memo);

element.header.layer = Lind;
element.header.floorInd = Find;
element.object.libInd = LibIndex;
element.object.reflected = false;
element.object.pos = PosXY;
element.object.level = PosZ;
element.object.angle = 0;

API_ParamOwnerType paramOwner;
BNZeroMemory(&paramOwner, sizeof(API_ParamOwnerType));
paramOwner.libInd = LibIndex;
err = ACAPI_LibraryPart_OpenParameters( &paramOwner);
if (err == NoError) {
API_GetParamsType getParams;
BNZeroMemory(&getParams, sizeof(API_GetParamsType));
err = ACAPI_LibraryPart_GetActParameters(&getParams);
if (err == NoError) {
ACAPI_DisposeAddParHdl(&memo.params);
memo.params = getParams.params;
(*memo.params)[ParaIndex + 0].value.real = EndX;
(*memo.params)[ParaIndex + 1].value.real = EndY;
(*memo.params)[ParaIndex + 2].value.real = EndZ;
}
ACAPI_LibraryPart_CloseParameters();
}
err = ACAPI_Element_Create(&element, &memo);

bool blnForce = true;
err = ACAPI_Element_RefreshElement( &element.header, &blnForce);

ACAPI_DisposeElemMemoHdls(&memo);

 

Hi,

 

There's no need to call RefreshElement in this case; the element creation handles that.

 

If that doesn't work, you can try the other way around:

- get original parameters from the library part (you may do that with `ACAPI_LibraryPart_GetParams()`, then you don't have to call OpenParameters/CloseParameters)

- create the element with those default parameters

- call ACAPI_LibraryPart_OpenParameters / ChangeAParameter / CloseParameters on the newly created object (fill the `guid` field instead of `libInd` in API_ParamOwnerType) → this ensures the parameter consistency

 

Best, Akos

Thank you for providing the workaround.
By the way, will the issue of "ACAPI_Element_RefreshElement()" not working properly in Archicad27 be fixed?

Solution

My understanding is that this solution is not a workaround. You shouldn't need an extra parameter script call when you place an element.

 

Looking at the source code, the function internally calls the parameter script with your parametrization, so I don't know what else to fix. Do you receive any errors?

 

Best, Akos

So the way the parameters were processed when creating the object was wrong in the first place.
I'll try reconstructing it.
If that doesn't work, I'll ask for your advice again.
note)
In the previous program,
In AC27.2.1, there is no error (NoError), but the GDL is not refreshed.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!