Boundary Curve

Closed curve connecting random points
//pts = Point.ByCoordinates(Math.RandomList(n)*53,Math.RandomList(n)*70,0);
pts = List.Flatten(Point.ByCoordinates((0..100..10)<1>,(0..100..10)<2>),-1);
def seq(pt:var[])
{
ct = Point.ByCoordinates(Math.Sum(pt.X)/List.Count(pt),
Math.Sum(pt.Y)/List.Count(pt));
qa = Math.Round(Vector.ByTwoPoints(ct,pt).Normalized().
AngleAboutAxis(Vector.YAxis(),Vector.ZAxis()));
q1 = List.GroupByKey(List.SortByKey(pt,qa)["sorted list"],
List.SortByKey(pt,qa)["sorted keys"])["groups"];
q2 = List.SortByKey(q1<1>,(Point.ByCoordinates(q1.X,q1.Y).
DistanceTo(ct))<1>)["sorted list"];
q3 = List.TakeEveryNthItem(q2,2,[1,0]);
q4 = List.Flatten(List.Transpose([List.FirstItem(q3),List.Reverse(List.LastItem(q3)<1>)]),-1);
return = q4;
};
pt1 = PolyCurve.ByPoints(seq(pts),true);