cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
GDL
About building parametric objects with GDL.

What is the best way to restrict an integer parameter to even numbers?

Reilly
Booster

I am trying to find a way to restrict user inputs for an integer parameter to only even numbers. What is the best way to do this?

 

For context: I have an integer parameter set up that allows a user to set the number of lite divisions in a window. In the vertical direction, the lites are divided between two sashes, so the number must be even or it throws off other dimensions. I could use a values command to create a list of available inputs, but I would like to find another way to restrict inputs to only even numbers if possible.

2 REPLIES 2
runxel
Hero

Fortunately that's possible and done easily:

values "my_int", range[2,20] step 2, 2

 

By using the "step" command you can choose start and step from there one.

All done in Parameter script.

Lucas Becker | AC 29 on Mac (Sequoia) | Graphisoft Insider Panelist | Akroter.io – high-end GDL objects | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text

My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
Jochen Suehlo
Moderator

I would offer a VALUES list with the values 2, 4, 6, 8, etc., as this is the clearest for the user.

Something like this would also work:

VALUES ‘anz’ RANGE[2, ] STEP 2, 2

Then odd values are rounded up to the next higher even value.

You can do something similar with PARAMETERS if you don't want the somewhat confusing limit indicator in the input field.

Jochen Suehlo . AC12-28 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de