Divide list by domains

Hi,

I have a list of numbers (e.g. 2068.445455) which I then round to a factor. So from 2068.45454 i get 2050. All nice and works

But then I need this factor to vary. So for numbers below 900 i need this factor to be 25 for 900-1500 50 and 200 for everything else above. I cannot do it. Pls Help! (below I show domains and corresponding to them factors)

It can be done with expression also, but this does it as well…

here it is with expression…

Round.gh (13.8 KB)

You nailed it. This is exactly what I meant.

When I plug my data into your script I get a result that for some reason omits some of data. Hope I can explain the problem with this picture.


As you can see all I change in your script are inputs(red). However the list I get as the result (the script above) omits some rows of the initial input list. Why?

I suspect it has something to do with this number in the top right corner of the panels (red).

Because you have 4 values above 2000 i.e. they are not included in any domain.

Silly me. Of course.
Thanks for that!

1 Like

This is just a screenshot of what I needed these numbers for. I needed to make the lengths of these timber baffles modular.

1 Like

@Jakinta
One more thing if you don’t mind…
When I plug in all my data into the script I get a list of number which is longer than the initial input list (red). This messes up things later on. I identified where this mismatch occurs (blue), can you have a look.

It is hard to tell without taking deeper inside, but it might be that you have coincident values with domain borders. For example 900- it belongs to 2 domains. Which is hardly possible. It is something related to data structure.
I would rather use expression version, beacuse it has more clear condition - “less than”.

So I blindly retyped your expression and it works with no problems.
Here’s result. It scales my timbers nicely.

I don’t understand your expression but thankfully it works haha. I will have to catch up on this in free time.

Thank you

you are welcome. The expression was included in file. :slight_smile:

1 Like