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

runxel
Ace

Reading from a text file is always problematic, because GDL will try to guess the type, thus leading to very nasty errors (think of a room schedule with the room numbers; you'd want e.g. "1.2345" to be text, not a number).

 

So I've mostly given up reading from text files, since it is so unreliable and impossible to control.

 

Also GDL arrays don't like to have mixed type in them.

If the first item in an array is text, the rest will be text, if the first is a number, the rest will be, too.

So my guess is: Your text file has different types as content which trips up Archicad.

Use XML instead.

AC 24 [ger] | Win 10 | Developer of the GDL plugin for Sublime Text |
«Furthermore, I consider that Carth... yearly releases must be destroyed»

I was aware of that, so I have seperated the operation in multiple simple ones, and it will not continue if the read values doesn't correspond to the parameter type (ie: text for text parameters, numeric for numeric parameters)

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.

@runxel 

 

Now I have a very strange behaviour

 

The 4 th parameter gets updated, but it only shows the values of the previous selection operation, not the updated one 😕😕😕😕😕😕😕😕😕 ???!!!!!*#

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.

Nader Belal
Mentor

Update:

I believe that somehow I'm near to the cause of my problems in GDL, it have to do with if...then..endif, number of Parameter Script execution and Branching decisions at the binary level not GDL

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.

Nader Belal
Mentor

Last Update:

I broke the GDL .... no seriously I really broke it.

Proof:
I have created an array variable ... filled it with string (after initiation)

Passed the values to corresponding parameter arrays in memory

 

Implemented change to the Parameters using Parameters Param=Variable

used Values{2} to get the results ... and bam The GDL editor refused it, saying that the String Parameter Array is a numeric Paramaeter

 

GzC3eXeg7g2yhX9hPuKgigO4yA0E-_kN_XTFbMlZF4k.jpg

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,

 

Could you send the code that did it? Words are not as precise as program code, and I don't understand what do you mean by "used Values{2} to get the results".

 

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

Try to set the array type prior to load (something[1]="" or something[1]=0) - it may help because avoids the "guessing" part.

Sometimes I try to lad the all as text and then further phrase....(I have to relay on some database export which is set to export as text so I have extra work..and I deal with 6000x60 or something csv)

Already done that

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.

I had stepped on something - maybe it is also Your case:

My scheme was to load data in macro which was called using returned_parameters, and when I had it in master script the call did not work. I had to move part of the script to the parameter script and it started to work as a charm.

Nope

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.

I agree with @runxel, reading text files is painful. Its much easier to read XML files for 2 reasons; all values are strings (even if numerical), and when the XML updates the changes occur automatically without having to reload.

Its hard to tell what your problem is without analyzing the code but one simple question comes to mind; do all your columns have the same number of values (same number of rows)?

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

XML is (or maybe was) unpredictable regarding the coding of text content - since it produced non consistent result i did not continue using it  😞  - with csv it is fairly easy, but not documented well- UTF8 with BOM and it works)

Nader Belal
Mentor

It wasn't XML

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.

without seeing the example code and example csv...probably all we said here will be guessing

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.

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

@Peter Baksa 

If you meant that I meant that the problem would be in reading the Text file have imposed (directly or indirectly) limitations to GDL, then I must apologies for my lack of clarity.

 

It's not the reading of the file that is causing all that trouble, it's the process of filtering values using nested IF ... Then ... Endif that is causing it.

 

In fact, as I have said it before, with the 5th nested IF ... Then ... Endif, I have tested the array type with Vartype, making sure that the variable array and parameter array are of the same type, then I tried to pass the variable array to the parameter array, to no avail, and when I managed to pass it, the debugger and the editor saw the text parameter as if it was a numeric array,  even when the values were pure text.

 

Anyway, eliminating one level of If...Then...Endif made everything work perfectly.

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.

This sounds like a problem with vartype, not nested ifs. A specific vartype can be tested without nesting ifs, does the problem still occur then?

The TEXT and DATA add-ons convert data looking like numbers to numbers even if the input variable is initialized to string.

Are you doing the input in a subroutine? The type of the variables is set by the input command during run-time, but types are checked when saving the object during script check. If the input type depends on parameters, you can have an error during script check which wouldn't occur during run or vice versa,

 

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

No, No, & No

 

First, I was working on Archicad 22.

Second, I used Vartype after I got an error message telling me that in the Parameter Script, Values{2} needed a text array after the integer array. So I put Vartype to know if I made the error after each array variable and after every corresponding array parameter to check if I made a mistake (which I didn't, including if I read the correct text column).

Third, I passed the needed values from the text file to the corresponding array separately, no only as Data content type, but also as text or numeric.

Fourth, Parameter Script run multiple of times, and in those iterations were the data was read correctly as a variable, they simply did not pass to the parameter array.

 

Fifth, Yes, I didn't pass the parameters values but at the end of the script that read the text data, but I also tried to do the same in the nested If...Then...Endif. the results were the same.

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.

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!