Help: Delete curve with Rhino Common

Hi All
How do I delete a curve?
I always get an error

# coding: UTF-8
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
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  
    #pt=objref.SelectionPoint() #punto di clik
    
    curva=objref.Curve()#id curva
    table=Rhino.DocObjects.Tables.ObjectTable.Document
    print table
    sc.doc.Objects.Delete(curva)  
    
deleteCurve()



Message: Delete() takes exactly 2 arguments (1 given)

Traceback:
  line 17, in deleteCurve, "C:\Users\Angela\AppData\Local\Temp\TempScript.py"
  line 21, in <module>, "C:\Users\Angela\AppData\Local\Temp\TempScript.py"

Ciao Vittorio

sc.doc.Objects.Delete(curvea, True)

Should do the trick. The second argument is for quiet - if not quiet, Rhino will show a pop-up if the object can’t be deleted. If quiet, it will ignore the error and keep going.

Apart from that, you are supplying an object to the Delete function, while it requires a guid:

# coding: UTF-8
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
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()

deleteCurve()

There are overloads to the Delete function that take Guids, RhinoObjects, or ObjRefs so both of your solutions should work just fine.

Thanks djordje

Your example it’s Ok
Ciao Vittorio