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

Select A Value By Index

Anonymous
Not applicable
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