I have a python script that (amongst other things) is supposed to delete objects. Currently I am unlinking the object but when I want to create objects later in the script with the same name as the deleted it is automatically named name.001 and so on. Is there a way to completely delete objects using a script?
1 Answer
bpy.data.objects.remove(bpy.context.scene.objects[id], do_unlink = True)
This should remove unlink the object from every scene you have. After that, the creation of a new object should go without the namechange.
bpy.objects.remove(ob)
) after unlinking. However a simple, and perhaps safer, workaround is to rename object (egob.name = "delete_me"
) before unlinking from scene, and let blender take care of removal if ob has zero users on save / reload. $\endgroup$