cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
HKM
Contributor

ACAPI_Element_RefreshElement() doesn't work on AC27

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 Solution

Accepted Solutions
Akos Somorjai
Graphisoft
Graphisoft

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

Go to post

13 Replies 13
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

Hiromichi Shinkawa
Graphisoft
Graphisoft

Hi,

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

 

HTH

HKM
Contributor

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.

HKM
Contributor
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);

 

Akos Somorjai
Graphisoft
Graphisoft

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

HKM
Contributor

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

Akos Somorjai
Graphisoft
Graphisoft

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

HKM
Contributor

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!