GroupByFunction missbehaving

Trying to group by length but for whatever reason there are problems. It makes more groups than necesarry. On the left is before - after grouping it should have 4 groups since it has 4 different values in that group. On the right is after grouping. It has 5 groups - for whatever reason there are 2 groups with equal values now.

I want to devide list in 4 groups like on the left. But after experimenting with levels and lacing can’t seam to get it right.

Looks to be a floating point error.

It looks like currently you’re in MM (1 4000mm long beam and a 500mm beam both make sense, but a 4000 meter beam and a 4000 foot beam doesn’t seem likely). And your values are currently showing 12 or 13 digits of precision, so unless your construction tolerance is 0.0000000005 times as long as a Bacterium, you’re tryinig to keep a precision beyond what is reasonable (well unless your contractors are walking around with electron microscopes). Add a Math.Round into your function to round your values to reasonable construction tolerance of say 0.01mm (ok that is still not reasonable but the computer will do math better at that scale anyway) and see what that gives you.

I’m not sure how to add rounding to function
This is what I tried:


It didn’t work

The functions would want to be wired into the Function.Compose in the order which they are executed; so get the parameter value by name, then round the value… or flip flop your inputs. :slight_smile:


Thank you very much, that solved it!
Is there a way to set the parameter to never have such high tolerance in the first place? I always deal with this while working with parameter numeric values.

Not really, and you likely wouldn’t want it as there will be instances where you want those extra degrees of precision (ie: trying to make a triangle close). As a computational designer you just need to learn when you need to take floating point into account, and act accordingly.

Generally speaking if I start to see numbers at which i couldn’t measure them with a standard measuring tape on a job site, then I consider adding a Math.Round into the mix. This is easier in metric as no one can really measure fractions of a mm, than imperial where 1/32 of an inch is the smallest measurement, but Revit refers to decimal feet so you need to care about 0.0026 unit intervals…

1 Like