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

dropdown list of an array element not possible ?

Anonymous
Not applicable
Hi,

In my object I need to specify x,y and type of hole
But there can be several holes
So i store them in a two dimensional array
tab_res[ i ][1] type of hole (0 -> no hole, 1 -> rectangle, 2 -> round)
tab_res[ i ][2] x of the hole in object
tab_res[ i ][3] y of the hole in object
tab_res[ i ][4] width of hole if rectangle
tab_res[ i ][5] height of hole if rectangle
tab_res[ i ][6] diameter of hole if round

so in the user interface i have fields to enter x, y width and height but for the type i would like a dropdown list instead of having to enter 0, 1 or 2
since the value is in a INT array, the value has to be INT
i saw we could associate STRINGs to INT using VALUES2
And do a dropdown with UI_INFIELD{3} method 8

so this is what i tried and no dropdown is appearing

MASTER SCRIPT:

NOHOLE = 0
RECTANGLE = 1
ROUND = 2
Parameter script:

for L = 1 to 4	
	values{2} "tab_res[" + str(L, 1, 0) + "][1]", NOHOLE , "No hole", RECTANGLE, "Rectangle", ROUND , "Round"
next L
UI script:

for L = 1 to 4
		UI_INFIELD{3} tab_res[1], 130, var_ligne, 40, 20,
                    8, "", 0, 0, 0,0,0,0,
		    "","Sans",NOHOLE,
                    "",'Rectangle', RECTANGLE,
                    "","Round",ROUND
next L
doing this the type field is still a numeric field, not a dropdown...
help !
5 REPLIES 5
Joachim Suehlo
Advisor
If I write instead
values{2} "tab_res", NOHOLE , "No hole", RECTANGLE, "Rectangle", ROUND , "Round"
it works for me. I never used a VALUES or VALUES{2} for single Array-Parameter-Values and I think that this does not work.
Joachim Suehlo . AC12-27 . MAC OSX 13.5 . WIN11
GDL object creation: b-prisma.de
Anonymous
Not applicable
Joachim wrote:
If I write instead
values{2} "tab_res", NOHOLE , "No hole", RECTANGLE, "Rectangle", ROUND , "Round"
it works for me. I never used a VALUES or VALUES{2} for single Array-Parameter-Values and I think that this does not work.
this can't work for me,
in the 2D array
each 1D array contains all necessary info for a hole, (type of hole, x, y, width, height, diameter)
and each first element of each 1D array needs to be one from: "no hole" -> 0, "rectangle" -> 1, "round" -> 2
Nader Belal
Mentor
Wait a minute cause I have already solved a similar problem
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
Ok got it

It's a design problem, and something contrary to the data theory (to the extends that I understand it).

First you must understand that you are mixing different data types in one parameters array, and that is a very bad idea in GDL, it's better to have multiple arrays, each for a distinctive type of data (ie: one parameter array for integer values - real values - etc), and by following GDL Styling recommendations it would be as following

iOpening_res[_i]			!<--for opening types (integer - array)
rOpening_res[_i]		!<--for opening real data (real - array)

second, if you follow the path I have just indicated, you would be able to use @Joachim Suehlo solution (actually he have already told you that, but in fewer words).

third, on another side, if you followed the database theory (i.e.: no data entry should be repeated), you will find that you have repeated yourself with tab_res[_i][6] column, while having tab_res[_i][4] and tab_res[_i][5] (that in your own words are used to length and height of a rectangle respectively), and as a pro-tip subtitude tab_res[_i][6] by tab_res[_i][4] (or with tab_res[_i][5] ), and depending on iOpening_res[_i] values of a specific index, xyOpening_res[_i][4] can be the width of a rectangle or radius/diameter of a circle.

forth cycling through parameter names in the way you have just shown us usually doesn't work (better said, never works in GDL)!
and if worked, it would be prone to errors and makes code maintainability quite difficult.

PS: Editied on 01/03/2020 for expression errors - "_i" was used instead of "i" because of forum's letter styling coding
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
 
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.