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

Use 3 buttons to select 3 different options from the same parameter?

JGoode
Expert
How can I have 3 separate buttons that can select a different option from the same parameter?

This is code that I've adapted from another object I have. Any help is appreciated.
	ui_infield{3} "existing", 0, 100, 100, 20,
	5, "", 1, 1,
	100, 100, 100, 100,
	1, e1,e1

	ui_infield{3} "existing", 0, 130, 100, 20,
	5, "", 1, 1,
	100, 100, 100, 100,
	1, e2,e2

	ui_infield{3} "existing", 0, 160, 100, 20,
	5, "", 1, 1,
	100, 100, 100, 100,
	1, e3,e3
ArchiCAD 23

Windows 10
2 REPLIES 2
Podolsky
Ace
The script is correct. Just you need to add to parameter script this line:

VALUES "existing", e1, e2, e3

And do not forget to define e1, e2 and e3 variables before execution of both commands - better in master script.
The way how your script is written, "existing" and e1, e2, e3 must be strings.
There are actually a few different ways to do this depending on what you want the UI to look like.

Podolsky is correct; first you need to set the parameter with the list of values in the master script (or parameter script but master is better).

Then you have options in the UI of:
USE the "ui_infield" command as you have done, which is probably the worst way (sorry, harsh but true).
or
USE the "ui_radiobutton" command, which I think is purpose built for exactly what you are trying to do. your UI script would look like this:


ui_radiobutton "existing", e1, e1, 	xPOS, 	yPOS, 20, 16: xPOS = xPOS +20
ui_radiobutton "existing", e2, e2, 	xPOS, 	yPOS, 20, 16: xPOS = xPOS +20
ui_radiobutton "existing", e3, e3, 	xPOS, 	yPOS, 20, 16: xPOS = xPOS +20

of
If you want a really nice UI with picture button that change based on the chosen button then USE
Use the "ui_button" command with the "ui_function" setting and assign a GLOB_UI_BUTTON_ID at the end:

ui_button ui_function, e1, 	xPOS, 	yPOS, 20, 16, 101: 	xPOS = xPOS +20
ui_button ui_function, e2, 	xPOS, 	yPOS, 20, 16, 102: 	xPOS = xPOS +20
ui_button ui_function, e3, 	xPOS, 	yPOS, 20, 16, 103: 	xPOS = xPOS +20

and then in the parameter script write the response to this button being clicked like:


if GLOB_UI_BUTTON_ID = 101 then parameters "existing" = e1
if GLOB_UI_BUTTON_ID = 102 then parameters "existing" = e2
if GLOB_UI_BUTTON_ID = 103 then parameters "existing" = e3

I hope that helps and doesn't confuse things further as having options often does. Basically, if you just need a check box for each option then use the "ui_radiobutton" as it is simple and fast to set up. If you want buttons with images or text then you need to use the last option.

Enjoy,
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