How to clear screen in blender with python

How to clear screen in blender


So far each time we run code we have to press "a" twice to clear the objects in the 3d view.
You can do that by code.

The code is pretty simplistic:

import bpy

bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)


As before we have to use " import bpy " else the python code will not work with blender


bpy.ops.object.select_all(action='SELECT')
#The above line selects all the objects on screen 

bpy.ops.object.delete(use_global=False)
# This line deletes all objects on screen 
# The use_global part will delete all objects from ALL scenes 

Here is the official list of object parameters for python in blender 


As before to run this code just press ALT+P or text> run
This will just clear the screen but will be useful for all future posts.


Comments