I was working on a script in Dynamo where at a certain moment the script should look at a list of points and index them by duplicates, like in the attached screenshot. Issue is, some of the points seem to be fractions of millimeters away from eachother. Using the Point.PruneDuplicates tolerance input, I noticed that one of the points is around 0.000000000001 (11 zeroes) away from another point. Because of this, the Lists.FindIndexesOf node doesn’t index them together like it does with the other points that are on the same coordinates. The desired outcome in this scenario is that list 0 in the last node contains each indexed points 0, 1 and 9 since these are on the same coordinates, however dynamo seems to think they’re a fraction away from eachother. It also thinks point 7 and 10 are different from 6, 8, 11 and 15. Which seems like more of the same issue. How do I fix this?
The Lists.FindIndexesOf is a node from SynthesizeToolkit.
This is also why Revit has a 22 mile limit, and why rhino models display funny when too far from the origin, and why developers don’t recommend testing for equality.
On the Dynamo side, there are lots of videos on the topic, as well as several forum posts which can provide insights into both the ‘why’ and a means of addressing the issue. In this case I would likely use a Geometry.DistanceTo function to compare the distance between the two values being less than a given tolerance, and then use the results to group things.
Looks like this would be the exact solution I need. When I directly copy the text in the node in the screenshot i get a couple errors saying the parameters aren’t available. After changing a couple parameters around I landed on this, which works perfectly, so thanks!
Actually interesting to know that it’s just a computer issue in general. Didn’t know something so trivial could be a universal issue amongst computers.
And to complicate things, the way floating points are calculated will vary by hardware, operating system, and software application.
So the same PC using the same [Dynamo, Python, DLL] which relies on any type of double comparison can return different results when you update windows. Or if you have the same windows but different hardware they can return different results.
In 1994 Intel famously had to recall $475,000,000 of Pentium processors in what was the first ever full recall of a computer chip.
But we digress…
A nodes only approach which won’t require rebuilding your points (a potentially slow operation, though this isn’t a trivial thing at scale) is as follows:
Prune the duplicate points using your desired tolerance
Get the distance from each point to all pruned points
Get the index of the minimum item in each sublist
Group the points by the minimum item index
In nodal form that looks like this (with a fun grouping display added for kicks ):