I need the user to pick a point at the end (or start) of a curve

I want to place an object at the end or start of a user selected curve.

so my question is:
what is the cleanest way to have the user pick the end (or start) of a curve?

I would like to do something like a GetObject geometryFiltered to ObjectType.Curve;

And then figure out which end they clicked the closest to when picking the curve.
(this clearly would not work if the command was being scripted.)

so right now I am doing a GetObject to pick the curve.
Then a GetPoint contrained to the curve. Then I figure out which end of the curve the selected point is closest to. But it would be nice if this was just one operation.

Can we constrain GetPoint to a supplied list of points? This way I could constrain the second GetPoint to just the Start or End of the selected Curve? (again this is a 2 step method, but better than nothing)

Use construction points. See http://4.rhino3d.com/5/rhinocommon/html/M_Rhino_Input_Custom_GetPoint_AddConstructionPoints.htm

For single click, you can do something like this:

GetObject go = new GetObject();
go.SetCommandPrompt("Select open curve");
go.GeometryFilter = ObjectType.Curve;
go.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve;
go.Get();
if (go.CommandResult() != Result.Success)
  return go.CommandResult();

double pick_t = RhinoMath.UnsetValue;
Curve curve = go.Object(0).CurveParameter(out pick_t);
if (null == curve || !RhinoMath.IsValidDouble(pick_t))
  return Result.Failure;

double curve_t = RhinoMath.UnsetValue;
Interval curve_domain = curve.Domain;
if (pick_t - curve_domain.Min < curve_domain.Max - pick_t)  
  // pick parameter closer to start
  curve_t = curve_domain.Min;
else
  // pick parameter closer to end
  curve_t = curve_domain.Max;

Point3d curve_point = curve.PointAt(curve_t);
doc.Objects.AddPoint(curve_point);
doc.Views.Redraw();

But this relies on the curve being post-picked. So if you don’t picking the curve and then a point on the curve as to separate operations, then you can move this logic into a custom GetPoint class that would do the constraining. For an example of this, see the attachment.

TestCsGordon.txt (2.6 KB)