I found several threads on this subject but could not distill a solution. I am trying to delete .001, .002, etc.
The code should delete these, but every time I rerun my code it is as if nothing was ever deleted; the count is now >0.250 and is rising rapidly.
Full disclosure: The solution below is inefficient; it is the culmination of several efforts to solve my problem and represents my final "brute force" approach.
Thanks in advance for your suggestions:
def delete_object_iteration(objname): for x in range(1, 999): xs=str(x) on2=objname+'.'+xs.zfill(3) try: bpy.data.objects.remove(bpy.context.scene.objects[on2], do_unlink = True) except: pass delete_object_instance(on2) def delete_object_instance(objname): try: bpy.ops.object.mode_set(mode='OBJECT', toggle=False) except: pass try: bpy.ops.object.select_all(action='DESELECT') bpy.data.objects[objname].select_set(True) bpy.ops.object.delete() except: pass ```