Grouping by their X values and sub grouped by their Y values, then subgroups are sorted by their Z values doesnt work entirely work because it won’t keep list order. ie this way Points above each other - #2 by Vikram_Subbaiah
Ended up with this:
Pull the point’s X and Y values, and merge them into a string. (p.X+””+p.Y;)
Group the points by that string using a List.GroupByKey.
List.MinimumItemByKey with correct lacing and list level input, using a Point.Z node as the projector will pull the lowest Z from each group.
No cross product lacing involved - the grouping will likely be the slowest action. Fortunately you could quickly limit that to quadrants of your project by only selecting points in one area at a time.
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
def XYHasAlready(pt):
global pruneLst
for idx, i in enumerate(pruneLst):
if abs(i.X - pt.X) < 0.01 and abs(i.Y - pt.Y) < 0.01:
if pt.Z < i.Z:
pruneLst[idx] = pt
return True
return False
inputPts = IN[0]
pruneLst = []
for pt in inputPts:
if not XYHasAlready(pt):
pruneLst.append(pt)
OUT = pruneLst