Deleting a curve using Rhino python

Hi,I wish to draw multiple curves and save each of them in a seperate file.In doing the same,I need to keep deleting the previous curve before saving the new one.I tried using 'del curve ’ command but it is not working.Can anyone suggest a working alternative for the same?

1 Like

I answered a previous thread in the same vein, but in order for rs.DeleteObject(obj_id) to work, you need to know the object id of the object you want to delete and supply it to the method.

–Mitch

1 Like

Hello,thanks for replying. I was able to delete the curve using the below function
def deleteCurve():
""“
Return list of curve and edge
”""
filter=Rhino.DocObjects.ObjectType.Curve
rc, objref = Rhino.Input.RhinoGet.GetOneObject(“Select curve”, False, filter)
if rc != Rhino.Commands.Result.Success: return rc
curve_id = objref.Object().Id
sc.doc.Objects.Delete(curve_id, True)
rs.Redraw()

Hello,I have a NurbsCurve instance .Can I somehow retrieve the object id so as to supply it to the method?

Is the Nurbs curve actually an object that has been added to the document? You can only delete it if it’s an actual Rhino object in the document and has an ID. Otherwise, it’s not necessary to delete it as it only exists “virtually” in memory.

–Mitch

Yes it is actually present in the document .After saving the file by a specific name ,I wish to delete the curve .As of now ,I am using getobject() which essentially needs an object/curve to be clicked manually and thereafter it retrieves its id and deletes .Also,I do have the curve instance which I used while drawing it.So ,if I am able to get the object/curve id without actually having to click it then it would be great.In other words,if I can retrieve the ID of the curve /object using its instance.