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

Problem passing values from Variable Array to Parameter Array

Nader Belal
Mentor

Hi everyone,

 

This is not a noob question.

 

Basically, I have created a Library part that reads a text file containing values that will drive the modeling of my object.

 

It's structured that it reads a predefined column, extract the unique values of that column and puts it in an array, then repeats that operation a multiple of times until it reaches to the last predefined column that have all the final unique values (about 4-5 times in total).

The problem arises after the third 3 column to be read, it simple does not update its values.

 

And the funny part is, the Variable arrays that are being used to update the Parameter Arrays, do get the updates, but the Parameter arrays do not get updated.

 

How do you overcome that ??

PS: There are not nested ifs...then...endif that exceeds the 3 level.

A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.
3 ACCEPTED SOLUTIONS

Solution
Nader Belal
Mentor

Hello everyone,

First of all, I want to thank you all for your effort and suggestions.

 

Second, I would like to give you the only answer I was able to reach with my limited knowledge and tools that I can master at the moment, after a lot of testing different methods, trial and errors, head scratching, and head banging against the wall.

We can simply put it this way ...

GDL have a limited capacity for nested IF ... Then ... Endif

 

Whether we like it or not, it's like that, there is no other way round, in fact I believe I have tested the maximum limits, which are:

  1. The safest option never go more than 3 levels of nested "If .. Then ... Endif". That if you want everything running smoothly and only if you value your peace of mind and sanity.
  2. If you must and need to go beyond 3 levels, because you have no other escape, you can go for 4 levels of nested "If .. Then ... Endif".
    But always have in mind that it only gives you 50% chance that it might not work.
  3. If you go for 5 levels, say to your mind ...

NaderBelal_0-1637777360073.jpeg

 

A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.

View solution in original post

Solution

I doubt this should be the final conclusion, let's investigate further.

 

Can you just read the file in one go, do all your modifications in memory, then write to parameters once?

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

View solution in original post

Solution

I have to admit you were right. I managed to re-create the problem with an array parameter. Without arrays the result is as expected.

We are inspecting this as a bug.

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

View solution in original post

25 REPLIES 25

I am not sure what is happening here, if you can send some stripped-down code & data we will look into it.

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Can't send it over here

A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.

Hi Nader,
Maybe a little bit late for you, but I have another Idee, why it does not work for you.
Graphisoft made a limitation in the Parameter Script running circles, to avoid the infinite loops in Parameter handling. It means if A drives B and B drives C, but C in the meantime drives A Parameter it generates an infinite loop and your parameter script will run until the end of time. To avoid this problem the Parameter script is running only a certain times and after stops to run. As I remember this maximal loop numer is 12 (but I'm not sure).
So, based on your problem, maybe it would be better to read your text file in an internal array first and only ones drive the Parameter to get these values.

Maybe it helps... 😉

I used more time more than 3 If Tags in my scripts, so I'm sure it is not the problem... 😉


G.

Go upwards a little bit and start reading from after the comment made by Piotr

A good friend of mine have once told me that I´m so brute that I´m capable of creating a GDL script capable of creating GDLs.

Solution

I have to admit you were right. I managed to re-create the problem with an array parameter. Without arrays the result is as expected.

We are inspecting this as a bug.

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

The problem is not with nested if's.

After a user interaction there can be several parameter script runs, a new one triggered by a values of parameters command, until the parameter values settle. In these batches of runs each parameter can be changed only at most once to avoid infinite loops caused by parameters changing eachother.

The contents of an array parameter aren't kept track of individually, the whole array can change only once. This is a necessary performance optimization.

So if your code needs to change contents of an array is several steps, you need to write it in a way there is only one parameters command, when the values are finalized for all possible conditions.

A generally good approach is making a copy of the parameter at the start of the script, so you can be sure whether you check the original or the modified content.

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!