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
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
Software Engineer Speckle Systems
Anonymous
Not applicable
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
Anonymous
Not applicable
and congrats for the nice and smart object!
Anonymous
Not applicable
Thanks Ralph. Like Olivier I thought Parameter arrays were fixed by their defined size. This is great news!
Anonymous
Not applicable
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.
Anonymous
Not applicable
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.
Anonymous
Not applicable
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...
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
Software Engineer Speckle Systems
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