Integers - maximum and minimum

Integers - maximum and minimum

phillipesfy_
Contributor Contributor
258 Views
2 Replies
Message 1 of 3

Integers - maximum and minimum

phillipesfy_
Contributor
Contributor

Hi all,

 

Just wondering if it's possible to add a maximum and minimum to an integer. I am currently using numbers 1-3 for visibility parameters, and would like to cap it to those numbers.

 

Thanks

0 Likes
259 Views
2 Replies
Replies (2)
Message 2 of 3

MetalFingerz
Advocate
Advocate

Hello @phillipesfy_ ,

 

You need to use a second parameter that will constrain the values of the first one. That second parameter is the one that you will use for your object while keeping the first one as a input.

 

So, let's say your input parameter is named VisibilityInput, then you would need another one that you could call VisibilityInputConstraint. Then VisibilityInputConstraint will be have a formula that would look like this :

if(VisibilityInput < 1, 1, if(VisibilityInput > 3, 3, VisibilityInput))

And like that, VisilibtyInputConstraint will always be between 1 and 3 and you will be able to use it to have values that are constrained between the minimum and maximum you want.

 

I would advise to have your minimum and maximum values as parameters as well so you do not have to hardcode them into the formula above.

if(VisibilityInput < VISIBILITY_MINIMUM, VISIBILITY_MINIMUM, if(VisibilityInput > VISIBILITY_MAXIMUM, VISIBILITY_MAXIMUM, VisibilityInput))

But that would also require you to have two additional parameters in your list so it's up to you and how many more parameters you're fine with.

0 Likes
Message 3 of 3

syman2000
Mentor
Mentor

I had similar formula that works with lengths but it should work integers as well. Check the screenshot

 

syman2000_0-1695914746891.png

 

Check out my Revit youtube channel - https://www.youtube.com/user/scourdx
0 Likes