I’m trying to remove points which are close to each other, but it says
Collection was modified; enumeration operation may not execute
whatever I do: .Remove() or .RemoveAt()
private void RunScript(List<Point3d> pts, double min, ref object A)
{
foreach (Point3d pt1 in pts)
{
foreach (Point3d pt2 in pts)
{
if (pt1.DistanceTo(pt2) < min && pt1.DistanceTo(pt2) != 0){
pts.Remove(pt2);
//pts.RemoveAt(1);
//pts.RemoveAt(-2);
}
}
}[reduce_the_density.gh|attachment](upload://fXobW5ZDWB80hrIVpGk5ou8CjGt.gh) (5.8 KB)
A = pts;
}
reduce_the_density.gh (5.8 KB)