GDL
About building parametric objects with GDL.

UI Scripting; Managing access to arrays

Aurasphere
Expert

I would like to use arrays for certain fields; is there a way to have the UI allow a drop down from an array field rather than what Im getting atm

 

Aurasphere_1-1719300787622.png

 

 

Manual states 

 

Aurasphere_0-1719300069390.png

I need a drop down for each array item and dont want this behaviour which jump s the user to an standard array input and not highlighting the relative index

 

Aurasphere_0-1719300739966.png

I would like each field to display the field value

 

Mark Wesse
AC26 | Win10 | Since v6.5r
Architerion - Architectural Systems Developer
Aurasphere - Acoustics
Building Biology - Human Compatible Architecture
"--- Every time...do it better ---"

2 REPLIES 2
Lingwisyer
Guru

What happens if you use ui_listfield?

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660
scottjm
Advisor

How are you structuring the parameter's array currently?  Do you have 24 separate parameters each with an array, or a single parameter with 24 items in the array.

If its a single parameter with 24 items to represent each component, you can just include the array index after the parameter name in UI_INFIELD .

 

 

ui_infield param[1]  x, y, width, height

 

 

However, to get the dropdown list of available items you need to use a index-string pair value set.

So instead of setting your parameter you are storing the information in to a String, set it to an Integer.

 

And then use the following Value code in your Parameter script:

 

dim aComponentsIndex[]
dim aComponentsDescription[]

aComponentsIndex[1] = 1 
aComponentsDescription[1] = "1 - PIERS"
aComponentsIndex[2] = 2
aComponentsDescription[2] = "2 - FOOTINGS"

VALUES{2} "param", aComponentsIndex, aComponentsDescription

 

 And an associated example in the Interface Script:

 

UI_INFIELD{3} param[1], 10,10,300,20
UI_INFIELD{3} param[2], 10,10,300,20
UI_INFIELD{3} param[3], 10,10,300,20
UI_INFIELD{3} param[4], 10,10,300,20
....

 

 

However that doesn't seem to be showing the the description in the UI field for some reason, so I had to go down the route of using the UI_INFIELD dropdown method.  Full script:

 

 

!! MASTER SCRIPT
dim aComponentsIndex[]				! Create the array to story the indexes of your dropdown list
dim aComponentsDescription[]		! Create another array for Description of each item in your dropdown list
dim aComponentsImages[]				! And a last array to link to an image file for each item - this isnt required but the UI_INFIELD was requiring something

aComponentsIndex[1] = 1 
aComponentsDescription[1] = "1 - PIERS"
aComponentsImages[1] = ""

aComponentsIndex[2] = 2
aComponentsDescription[2] = "2 - FOOTINGS"
aComponentsImages[2] = ""

!! create the additional items in your dropdown in the above format




!! PARAMETER SCRIPT
VALUES{2} "param", aComponentsIndex, aComponentsDescription



!! INTERFACE SCRIPT

row_height = 20  	! Set the Height of each input row

for i=1 to 5  		! Loop through each item in the parameters array to display an input

	UI_INFIELD{3} param[i], 10, 10+row_height*i, 300, 20 ,							! parameter, x,y,width,height
					8, "",															! method:dropdown, picture_name: n/a
					0, 																! images_numer:n/a
					0, 0, 0,														! rows_number:n/a, cell_x:n/a, cell_y:n/a,
					0, 0,															! image_x:n/a, image_y:n/a,
					aComponentsImages, aComponentsDescription, aComponentsIndex		! the arrays containing the images, description and index of the dropdown list


next i

 

 

 

Frustratingly whenever I tried to use "" in place of aComponentsImages it was only giving a warning, but then wasnt working, so i had to create a separate array to story the blank strings for the image component of the UI_INFIELD dropdown.  

 

Anyone else know how to avoid that?

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe