Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Limiting Range Of Parameter Arrays

Anonymous
Not applicable
Hi all,
I am trying to figure out how to create a limit range for an object with parameter arrays, using a loop.
basically it is just a grid with adjustable grid line lengths controlled by loops:

for i = 1 to nGridLines
add2 gridLineX, 0
gosub “Grid Line”
del 1
next i

however i want to limit the minimum & maximum spacing for the grid spacing:
this is what i would do if it was not an array:

VALUES "gridXPosition" Range [1, 5]

Help me please!

Thank you
33 REPLIES 33
Anonymous
Not applicable
FOR i = 1 TO nGridLines
VALUES gridlineX RANGE [1, 5]
NEXT i
ztaskai
Graphisoft Alumni
Graphisoft Alumni
Unfortunately, there is no way to define values for array type parameters:(

There are workarounds for 2 situations, though.

For parameters which appear in the parameter list and/or in the UI page, you should add a non-array parameter which represents only one element of the array and an integer or other chooser by which the user can control which array element to manipulate. In this case the non-array parameter can have a range. You can see this "one-from-many" interface in the 1st UI page of the Material Legend object of ArchiCAD Library 13.

For parameters which can be changed via hotspots, you can use the PARAMETERS command in the following fashion:
for i = 1 to nGridLines
    if gridXPosition < 1 then
        gridXPosition = 1
    endif
    if gridXPosition > 5 then
        gridXPosition = 5
    endif
next i
parameters gridXPosition = gridXPosition
I hope one of these methods will help you.

Regards,
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Joachim Suehlo
Advisor
Unfortunately, there is no way to define values for array type parameters:(

Zsolt, let me see this in another perspective:
If you change your parameters in the User Interface, you can define values for array type parameters as whole; but this is the only 🙂

Let me give you the long expected wish to make values available for single array parameters and for moveable hotspots as well in a future GDL version.
Joachim Suehlo . AC12-27 . MAC OSX 13.5 . WIN11
GDL object creation: b-prisma.de
Anonymous
Not applicable
Zsolt,

Thanks for the correction. It's been a long time since I did it and I thought I recalled using the VALUES statement. Now I remember that failing. Seeing your code reminded me of how I finally got it to work.

It would be nice to get the VALUES to work with with array parameters though.
Anonymous
Not applicable
Hello Zsolt,
by the way I was wondering if there was a way for using dynamic arrays as input parameters.
If I'm not clear:
I can define a dynamic array like this in the script: dim myArray[][]
But if I wanted that myArray to be available as a parameter input (in the UI) then I can't. I have to give its dimensions, and they can't be changed.
Is that right or is there a workaround?
Thanks in advance,
Olivier
ztaskai
Graphisoft Alumni
Graphisoft Alumni
We know this wish for a long time but I don't consider this as highly important. I can tell you why:

You shouldn't put array parameters directly in the parameter list or in the interface anyway.

Which solves the dynamic sizing problem of Olivier, too. You can have a parameter for the size of the array (see Material Legend, again), which is usually a meaningful number not just the size of an abstract storing mechanism. And using that you can reset the array parameter having the new size via the PARAMETERS command.

Naturally, having VALUES for array members would make hotspot editing more straightforward. It is definitely a valid wish. Still, I think this new kind of VALUES won't come very soon.

I hope not to disappoint you! 🙂

Regards,
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Ralph Wessel
Mentor
Olivier wrote:
Hello Zsolt,
by the way I was wondering if there was a way for using dynamic arrays as input parameters.
If I'm not clear:
I can define a dynamic array like this in the script: dim myArray[][]
But if I wanted that myArray to be available as a parameter input (in the UI) then I can't. I have to give its dimensions, and they can't be changed.
Is that right or is there a workaround?Olivier
Yes, you can do both.

1) Data can be entered into a parameter array using ui_infield{2}. From the GDL reference manual:
name: parameter name as string expression for UI_INFIELD or parameter name with optional actual index values if array for
UI_INFIELD{2}

2) A parameter array can resize dynamically. Again, from the manual:
Parameter arrays do not have to be declared in the script and they are dynamic by default.
...and furthermore:
For dynamic arrays there is no limitation for the actual index value. During the interpretation, when a non-existing dynamic array element is given a value, the necessary quantity of memory is allocated and the missing elements are all set to 0 (numerical).

Just be sure to use the parameters function when resizing the array to ensure the actual parameter value is updated.
Ralph Wessel BArch
Joachim Suehlo
Advisor
You shouldn't put array parameters directly in the parameter list or in the interface anyway.
Zsolt,
thank you for the tip; it is a very interesting method that will solve a lot of problems.
But if I want to have many parameters of one array parameter to be shown on a single UI-Page I have to use them directly.
Joachim Suehlo . AC12-27 . MAC OSX 13.5 . WIN11
GDL object creation: b-prisma.de
Anonymous
Not applicable
Hello Ralph,
I know both of these two points, the problem is to define the parameter to be filled in as a dynamic array. As far as I know for an array to be dynamic you have to initialize it by dim ar[][]. And you can't do that for paramaters input. You have to give them dimensions, and then your are limited.
Or did I miss something? can an array in param input with [1][1] become dynamic?