BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

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

How increase size of parameter array in object instance?

Anonymous
Not applicable
I need to increase or resuce count of the items in parameters array.
But I have error where assign to .ind1 value more than size of array, defined on the lib part.

chgParam.ind1 = 5;
chgParam.realValue = 10;
err = ACAPI_Goodies (APIAny_ChangeAParameterID, &chgParam, NULL);

Can I increase size of the parameter array dynamicly, without changing a lib part?

Help me please...)
9 REPLIES 9
Oleg
Expert
I dont know how to do it by the APIAny_ChangeAParameterID function.
May be it is possible.

But you can to change a parameter value array directtly:

1. Get the element memo of an object instance
ACAPI_Element_GetMemo, APIMemoMask_AddPars flag

2. Find the API_AddParType by parameter name in the memo.params handle

3. Reallocate "array" field of this API_AddParType structure
and assign valid dim1, dim2 fields

4. Update changes by the ACAPI_Element_ChangeMemo

PS:
If it is you own lib.part, also you can to try other trick.
( just idea, i am not sure it will work )
Add a special hidden parameter to this lib.part - "dimension size".
The GDL parameter script have to change the array size as this parameter.
Change this parameter by APIAny_ChangeAParameterID to resize the array by GDL.
Ralph Wessel
Mentor
Tsepov wrote:
I need to increase or resuce count of the items in parameters array.
But I have error where assign to .ind1 value more than size of array, defined on the lib part.
I haven't tried using APIAny_ChangeAParameterID to change the bounds of an array, but I doubt it's able to. We do the same as Oleg – work on the parameter memo data associated with the element.
Ralph Wessel BArch
Akos Somorjai
Graphisoft
Graphisoft
Tsepov wrote:
I need to increase or resuce count of the items in parameters array.
But I have error where assign to .ind1 value more than size of array, defined on the lib part.

chgParam.ind1 = 5;
chgParam.realValue = 10;
err = ACAPI_Goodies (APIAny_ChangeAParameterID, &chgParam, NULL);

Can I increase size of the parameter array dynamicly, without changing a lib part?

Help me please...)
No, you can't change that, because the dimensions are defined in the library part itself, and here you want to modify that via a placed instance. So please define the max dimensions in the library part itself.

Best, Ákos
Anonymous
Not applicable
Thank You!

I had to pre-set in the library element the maximum number of rows in the array and in another parameter to record the number of employees.
In principle, the idea works.
Ralph Wessel
Mentor
Akos wrote:
No, you can't change that, because the dimensions are defined in the library part itself, and here you want to modify that via a placed instance. So please define the max dimensions in the library part itself.
Library part instances can dynamically change the array bounds (for that instance) within the GDL script and we routinely do that via the API too. Changing the array bounds of the library part has no affect on placed instances, i.e. they retain their original content (unless the variable is no longer an array).
Ralph Wessel BArch
Anonymous
Not applicable
I tried do it so:
I create a library element with the parameter my_array [2] [2]. Put into the project one and the second instance.
Then I open the second one, in the editor and manually change my_array [2] [3].
Save it.
As a result, the first Instance remains [2] [2] and the second [2] [3].
But to get access to write data from the API to the first one is no longer possible.
It gives an error.
Anonymous
Not applicable
In any case, the possibilities are already enough.
The idea is as follows:
GDL BIM element creator (anybody) can create objects whose area or volume figures is restored by coordinates from the parameter array by EXTRUDE or other GDL commands.
Now his users can use free addons, which takes the hatching and writes coordinates to this array.
The same addons can restore the shading from the array so that the GDL user of the element can change the form and write the changed form back to the element.
One of the GDL objects, that use this method is a frame with any form hard.
It not needed to save new library element for new form.
http://www.labpp.ru/en/labpp-goodwingdl/57-gude-labpp-goodwingdl

Simply the creator of the object's GDL must pre-set a sufficient number of rows in the coordinate array.

But control size of the array by API would be preferable.

Maybe there is some other way to write data to the GDL element for store coordinate array with variable length?
Ralph Wessel
Mentor
Tsepov wrote:
Simply the creator of the object's GDL must pre-set a sufficient number of rows in the coordinate array.

But control size of the array by API would be preferable.

Maybe there is some other way to write data to the GDL element for store coordinate array with variable length?
You can dynamically change the size of an array in an object instance via both GDL and the API. But you need to read/write the parameter memo data for the object element to make this work.
Ralph Wessel BArch

I'm trying to follow this but having a hard time with reallocating array field. Could you elaborate on this? Does the array need to be GSHandle type and how does one determine its size?

Learn and get certified!