 # Pull point in c#

Hi all,

What is the rhinocommon equivalent of the Pull Point grasshopper component?
https://rhino.github.io/components/vector/pullPoint.html
Specifically, a method that returns, from a set of points, the closest point only to the closest geometry within a list of geometries (as oppose to the standard ClosestPoint component).

Thanks!

There is no direct Rhinocommon equivelent. Pull point has various conditions for each geometry type and it uses a bunch of looping with closest point rhinocommon methods to find those closest points.

Hi Michael, thanks! Let’s say I’m only interested in Curves as the pulling geometry type for now. I’m interested in how the Pull Point component is so much faster than doing a CurveClosestPoint and then sort?
Attaching a test: pullpoint_test1.gh (365.5 KB)

I don’t know the exact code in the components but my guess is that the sorting for closest is simply just faster as a loop inside a script vs as separate GH components.

Thanks again, Michael. I tested with a C# version, and it is only slightly slower then the pull component on the closest option, if anyone is interested:

``````    Point3d[] p_arr = p.ToArray();
Curve[] c_arr = c.ToArray();
double[] d_sorted = new double[p.Count];
Point3d[] p_sorted = new Point3d[p.Count];

for(int i = 0; i < p.Count; ++i){
double t;
double[] d_temp = new double[c.Count];
Point3d[] p_temp = new Point3d[c.Count];
for(int j = 0; j < c.Count; ++j){
c[j].ClosestPoint(p[i], out t);
Point3d pt = c[j].PointAt(t);
Vector3d vec = new Vector3d(pt - p[i]);
double d = vec.Length;
d_temp[j] = d;
p_temp[j] = pt;
}
Array.Sort(d_temp, p_temp);
d_sorted[i] = d_temp;
p_sorted[i] = p_temp;
}

A = p_sorted;
B = d_sorted;``````