Round the Value to Nearest Ceiling Value of Given List

Hello, a novice grasshopper user dabbling in math components. As said in title, I have a value that i wish to round off to the nearest Highest value present in a given List. I tried the pufferfish component but it gives the nearest floor value not the ceiling value. I am pretty sure there is an easy solution to this which I am missing. Thank you for your help.

Try the standard Round component that comes with Grasshopper. It outputs among other things the ceiling value.

Post a GH file with your inputs and expected output.

Maybe the teal colored ‘Round To Fraction’ group in this post?

hi thank you for the replies. I have linked the GH file here. The standard round component doesn’t have an input for a custom list as far as I know.
Round to nearest highest.gh (6.0 KB)

missing

This file is useless!?

I am not sure how u are getting that error. I am using Rhino 7 and have the plugin Puuferfish installed in it if it helps.

I try to avoid threads where no GH/geometry is posted… but keep failing.

Round to nearest highest_2021May11a
Round to nearest highest_2021May11a.gh (5.8 KB)

Thank you for the reply but that is not the output I am looking for. Maybe this image will help.

Here’s a little Python script that does the trick!

Screenshot 2021-05-11 at 19.28.14

If x is included in L, then F will be equal to x!

Round to nearest highest 2.gh (4.5 KB)

Fooled again! :man_facepalming: I know better, I really do… NEVER respond to a thread without a clearly stated objective!

Thank you

You’re welcome!

Follow up question:
If i want a single output value which is either the higher ceiling value if its not on list or if its on the list the same value. How do i go about making it happen?

Simply like this:

Round to nearest highest 3.gh (4.7 KB)

Thank you very much

Here’s a revised version of the script!
The previous one only works if L is presorted.

Round to nearest highest 3b.gh (4.7 KB)

That shouldn’t be an issue anymore.

1 Like

Using standard GH components:


Round to nearest highest_2021May11b.gh (7.3 KB)

Looking back on my notes, I do have adding this functionality written, just never got to it. Next time!

Indeed, prolly why this question is in the Puffefish category :wink:

This isnt correct in one case, if you put 7 in you should get 9 out if it is really a ceiling no? This still gets 7. Or do you think that if a number is hit exactly than floor and ceiling should be that number. Curious what is the better functionality.