Iterate over a block definition and delete objects in Rhinoscript

HI guys,
I am pretty bad in rhinoscript could you look at this? Something tells me I should go to a deeper level than the block istance but I am not sure what to do

objects=rs.GetObjects()

for obj in objects:

#block_id = rs.GetObject("Select block", rs.filter.instance)

# Get the name of the block definition
block_name = rs.BlockInstanceName(obj)

# Get the block definition's objects
object_ids = rs.BlockObjects(block_name)

count= 0
# delete just the curves inside the block

for id in object_ids:
    if rs.IsCurve(id)==True:
        count=count+1
        
        ################################# this is not working
        rs.DeleteObject(id)
        
if count>0:
    
    print "in the block",block_name," ",count," curves were deleted"
else:
    print "in the block there are no curves"