Force to delete datablock?

Is it possible to completely remove datablock?

I need to replace a lot of actions a lot of time, so I wrote a script that remove the fake user and all users but I still need to save the file and reopen it to have a clean file and then I can import the new datablock.

Is there a way to remove datablocks without reopen the file?

No, saving and re-opening is currently the only way to actually remove datablocks.

bpy.data.meshes.remove(bpy.data.meshes[‘Mesh’]) seemed to remove it from the meshes drop down?

Oh yes, datablock.remove() works for me! :slight_smile: Thank you!

The problem with .remove() is that all users must be cleared, but forcing it with user_clear() will most certainly lead to crashes later on.

Granted there are no users, remove() should work indeed.

Thank for the advice. Why user_clear() would lead to crash?

Because it doesn’t remove references from other objects to this datablock. As soon as an actual user tries to access the removed datablock, Blender will crash (I assume it’s a dangling pointer, trying to read from the memory address it points to is an access violation).