Removing curve grips within python

I want to be able to automatically select and delete grips from a curve object using a python script, i.e. if two grips were very close together.

The example below seems to fall down because it’s looking for a point on the curve rather than the grip itself. It’s probably possible to write a separate function to find the closest point on the curve to the grip, but is there a more straightforward way of removing a grip from an object?

import rhinoscriptsyntax as rs

# Curve from points
point_list = [(0, 0, 0), (0, 1, 1), (0, 15, 5), (0, 3, 6), (0, 20, 20)]
curve = rs.AddCurve(point_list)

# Curve control points
control_points = rs.CurvePoints(curve)
point_to_remove = control_points[1]

# Attempt to remove second point from curve
rs.Command("-_RemoveControlPoint " + "selid " + str(curve) + "_enter " + 
    "selid " + str(point_to_remove) + " _enter ")


you might use these methods to select object grips and then run the _Delete command using rs.Command. Alternatively, why not use _FitCrv command ?


Perfect, thanks, I didn’t realize you could just use _Delete. _FitCrv is a better suggestion though