0
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ Can remove object from the collection (bpy.objects.remove(ob)) after unlinking. However a simple, and perhaps safer, workaround is to rename object (eg ob.name = "delete_me") before unlinking from scene, and let blender take care of removal if ob has zero users on save / reload. $\endgroup$ – batFINGER Feb 26 '17 at 16:23
0
$\begingroup$
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.