cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Select A Value By Index

Is there any way to set a parameter's value by using an index? I want a default to be the second item in a value list because the first value is always `0`.

VALUES Light_Frame_Qty `0`, `10`, `20`
IF Selected = `-` THEN
PARAMETERS Light_Frame_Qty = `0`
ELSE
PARAMETERS Light_Frame_Qty = [index2]
ENDIF

It's easy enough to use the value `10` in place of [index2] when there is only one of these, but if you have 20 very different parameters (and I do) it would be much quicker to code using the index.
1 Reply 1
Frank Beister
Moderator
Try this (from brain to keyboard, not tested):
DIM QTY_val []
QTY_val[1] = `0`
QTY_val[2] = `10`
QTY_val[3] = `20`
VALUES Light_Frame_Qty  QTY_val

VALUES Selected 1,2,3

IF GLOB_MODPAR_NAME="Selected" THEN
  PARAMETERS Light_Frame_Qty = QTY_val[ MAX(1, MIN(Selected,VARDIM1(QTY_val) ) ]
  ENDIF
bim author since 1994 | bim manager since 2018 | author of selfGDL.de | openGDL | skewed archicad user hall of fame | author of bim-all-doors.gsm
... und im Übrigen bin ich der Meinung, dass Trockenbauwände einschichtig zu modellieren sind.

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!