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
  • 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$ Commented Feb 26, 2017 at 16:23

1 Answer 1

1
$\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$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.