Skip to main content
added 1 character in body
Source Link

Just to add up to the great answer above, one must be in OBJECT mode in order to delete objects. In order to do so in Python use the following code:

bpy.ops.object.mode_set(mode='OBJECT')

It also makemakes sense to return to previous mode, after the operation:

oldMode = bpy.context.mode
bpy.ops.object.mode_set(mode='OBJECT')
 ...Select your object here
bpy.ops.object.delete()
bpy.ops.object.mode_set(mode=oldMode)

Just to add up to the great answer above, one must be in OBJECT mode in order to delete objects. In order to do so in Python use the following code:

bpy.ops.object.mode_set(mode='OBJECT')

It also make sense to return to previous mode, after the operation:

oldMode = bpy.context.mode
bpy.ops.object.mode_set(mode='OBJECT')
 ...Select your object here
bpy.ops.object.delete()
bpy.ops.object.mode_set(mode=oldMode)

Just to add up to the great answer above, one must be in OBJECT mode in order to delete objects. In order to do so in Python use the following code:

bpy.ops.object.mode_set(mode='OBJECT')

It also makes sense to return to previous mode, after the operation:

oldMode = bpy.context.mode
bpy.ops.object.mode_set(mode='OBJECT')
 ...Select your object here
bpy.ops.object.delete()
bpy.ops.object.mode_set(mode=oldMode)
Source Link

Just to add up to the great answer above, one must be in OBJECT mode in order to delete objects. In order to do so in Python use the following code:

bpy.ops.object.mode_set(mode='OBJECT')

It also make sense to return to previous mode, after the operation:

oldMode = bpy.context.mode
bpy.ops.object.mode_set(mode='OBJECT')
 ...Select your object here
bpy.ops.object.delete()
bpy.ops.object.mode_set(mode=oldMode)