Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

Compare a number list with float input

$
0
0

Hello,
this might be a very simple and stupid question, but I’m new to using Python within Grasshopper (using Python in general, I do have some basic understanding, but used a different language before).
I wanted to sift a given list of decimal numbers (values coming from the Elefront component) by boundary numbers. E.g. if my list contains (1.1 , 1.6 , 0.8 , 2.4) and my boundaries are 1.0 and 2.0, it should do:
below 1.0: add 0 to sift pattern
between 1.0 and 2.0: add 1 to sift pattern,
above 2.0: add 2 to sift pattern.
So the example above should create a patterns like this (1 , 1 , 0 , 2)
To be more in charge of what numbers are my boundaries, I didn’t want to hard code them all into the Python script, but rather be able to adjust them within Grasshopper. That’s why I created these additional inputs. But for some reason, everything gets sorted into the last group of my sift pattern (shown in the Panel on the right bottom - there shouldn’t be 4 everywhere).
I thought, converting the inputs to float might help, but it didn’t. So now I’m a little lost where this error occurs. Does anyone knows anything?

Best,
Carina

PS: I’m sure, there is a more efficient way to code this. Right now I’m trying to reach the state of ‘it works so far’. :sweat_smile: I’m still grateful for coding advise!

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles