Design forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Limiting Range Of Parameter Arrays

Dwayne Murphy
Newcomer
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
Chur,
Dwayne

INTEL(R) Core(TM) i7-2630QM CPU @ 2.00GHZ
NVIDIA Quadro 1000M
12.0Gb ram/ Windows 7 professional 64bit/ AC14, AC15
33 REPLIES 33

Matthew Lohden
Newcomer
FOR i = 1 TO nGridLines
VALUES gridlineX RANGE [1, 5]
NEXT i
Matthew Lohden
Consultant, SF CA

MacPro 8core 32GB Radeon 5870
OSX 10.8 Mountain Lion, XP32, Win 7x64

ztaskai
Newcomer
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
Advocate
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-25 . MAC OSX 10.15 . WIN10

Matthew Lohden
Newcomer
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.
Matthew Lohden
Consultant, SF CA

MacPro 8core 32GB Radeon 5870
OSX 10.8 Mountain Lion, XP32, Win 7x64

Olivier Gras
Newcomer
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
"Il faut bien supporter quelques chenilles pour voir des papillons"
A. de St Exupery

ztaskai
Newcomer
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
Advocate
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-25 . MAC OSX 10.15 . WIN10

Olivier Gras
Newcomer
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?
"Il faut bien supporter quelques chenilles pour voir des papillons"
A. de St Exupery

Ralph Wessel
Mentor
Olivier wrote:
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?
As the reference manual states, parameter arrays are automatically dynamic. Although you may specify a size, this can be increased as required by any instance of the object. I make extensive use of this in the Modular Joinery object. Using the attached image as a reference, we can see this in action:
  • 1. The default window has 3 cells: an enclosing frame, 1 window, and 1 pane within the window. The cell allocation array is therefore set to 3 (see the associated parameter list)

    2. If I bump up the number of windows across to 2, the unit still has a single enclosing frame, but now has 2 windows and 2 panes (1 per window).

    3. We can see in the parameter list that the cell allocation is increased to a total of 5.
You can even make use of dynamic arrays and apply bounding constraints with dynamic arrays. Again, referring to the attached image:
  • 4. I have used the Modular Joinery object to create a unit with a central door surrounded by an array of windows and panels. I have specified that the structural opening size is fixed and that the width of the door is fixed. Note that there are hotspots at all the dividing rows and columns that can be dynamically stretched.

    5. If I grab the hotspot to the left of the door and drag, the panel to the left shrinks and the panel to the right expands. The door remains a constant width (as specified). However, the hotspot is constrained by the minimum pane size of the windows to the left so the door cannot be stretched too far to the left.

    6. The door stretched as far as the constraints allow to the left.

    7. And in the opposite direction, constrained by the windows to the right.
By using dynamic arrays, the object can cater for very small or very large joinery units, but always using the minimum amount of memory required.
Array.jpg
Ralph Wessel BArch

Olivier Gras
Newcomer
Wow that's great! it opens up a world of possibilities!
Well the wall was in my mind obviously, I didn't even thought it was possible.
It will be hard to not digg into GDl this week even if other things are on the table.
Until now I always initialized parameters arrays with big numbers, which is bad for memory and not easy to use. I had to click a lot (like 50*50), and I feel stupid.
Then I remember that I tried to experiment to see if they were dynamic and my conclusion was "no", but I must have done something wrong, possibly cos i was pessimistic.
Thanks for the good news,
cheers,
Olivier
"Il faut bien supporter quelques chenilles pour voir des papillons"
A. de St Exupery

Olivier Gras
Newcomer
and congrats for the nice and smart object!
"Il faut bien supporter quelques chenilles pour voir des papillons"
A. de St Exupery

Matthew Lohden
Newcomer
Thanks Ralph. Like Olivier I thought Parameter arrays were fixed by their defined size. This is great news!
Matthew Lohden
Consultant, SF CA

MacPro 8core 32GB Radeon 5870
OSX 10.8 Mountain Lion, XP32, Win 7x64

Braza
Newcomer
Ralph wrote:
By using dynamic arrays, the object can cater for very small or very large joinery units, but always using the minimum amount of memory required.
Very interesting!...

Ralph... Could you please give us a small sample code using this dynamic array concept applied to multiple editable 2d/3d hotspots?...

As Olivier, I'm using parameters with fixed arrays in my objects and it would be nice to have better memory handling with this technic.
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

Matthew Lohden
Newcomer
If I understand Ralph correctly the Parameter arrays are automatically dynamic. This would mean that the setup button is just for entering default values and that the size of the array will expand to accommodate whatever is scripted using the PARAMETERS statement.
Matthew Lohden
Consultant, SF CA

MacPro 8core 32GB Radeon 5870
OSX 10.8 Mountain Lion, XP32, Win 7x64

Braza
Newcomer
Let me put it in a practical situation:

I have a 3d line object with an user defined number of nodes...

Each one of these nodes have an individual 3d hotspot that controls its height...

Within those 3d hotspots I've created an array parameter called "NodeHeight" and defined it in the parameter list as "NodeHeith[50]"...

The thing is: Am I limited with this 50 instances or can I control it with a specific Dim NodeHeight[] script?...

And of course creating a dynamic (unlimited) number of editable 3d hotspots...
Paulo Henrique Santos, Architect
AC24_INT#3008 / I7 / 16Gb / 512Mb SSD / Windows 10

Braza: the whole idea is: using put and get - pour one array to another (the temporary) - while doing so making the modifications etc, and than using parametrs command modify the original array by pouring the temporary array to the original one.

Best Regards,
Piotr

Ralph Wessel
Mentor
Piotr wrote:
Braza: the whole idea is: using put and get - pour one array to another (the temporary) - while doing so making the modifications etc, and than using parametrs command modify the original array by pouring the temporary array to the original one.
Not exactly - there isn't any need for a temporary array because the parameter array is itself dynamic and provides everything you need. If you need to allocate a new row for an integer array called myArray, you could simply write:
nextIndex = vardim1(myArray)
parameters myArray[nextIndex] = 0
The array will have one extra row every time this executes.
Ralph Wessel BArch

Ralph wrote:
Piotr wrote:
Braza: the whole idea is: using put and get - pour one array to another (the temporary) - while doing so making the modifications etc, and than using parametrs command modify the original array by pouring the temporary array to the original one.
Not exactly - there isn't any need for a temporary array because the parameter array is itself dynamic and provides everything you need. If you need to allocate a new row for an integer array called myArray, you could simply write:
nextIndex = vardim1(myArray)
parameters myArray[nextIndex] = 0
The array will have one extra row every time this executes.
My idea was for the implementation Braza asked (line/polyline 3d)...while doing temporary array - you may check where to add a point or where to remove it - and then the whole change can be poured to the final array.
(I did implement this in couple of objects - including the editable poly inside, I did implemnt the same in some kind of table editor that is able to add or remove row/column anywhere I want)
Maybe there is a way of avoiding the extra temporary array...

Best Regards,
Piotr

Didn't find the answer? Start a new discussion

Labels

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!