How can I completely remove a objects (e.g. particle system or groups used in particle systems) in blender using python?
The problem is this: I have a script, with which I create a scene (e.g. adding some normal objects and some group of objects with a particle system). For a research study I would like to repeat that that several times, without restarting blender. So I can create a scene, delete everything, e.g. with a script like this:
import bpy scn = bpy.context.scene for obj in scn.objects: obj.select = True bpy.ops.object.delete()
If I rerun the script to recreate the scene with objects using particle system, the latter is not shown in the scene anymore (only the placeholders of the particle system). Now I'm not sure where exactly the problem lies, but I guess not everything is immediately deleted, running the script above. Only the startup of blender helps (but that's not what I want) or pushing the purge button. The purge button seems to start the command:
But I can't get this piece of code to run in the console. It says that "the context is incorrect". Is there a way to purge the unused data by python script? Thanks a lot for any help.