I'm trying to make a simple program where 15 spheres are randomly placed into a 20x20x20 volume, then after two seconds it clears all the spheres and places another 15 randomly.
It will place the first 15 spheres fine after two seconds, then after another two seconds blender closes.
Any help with this is much appreciated.
import bpy
import random
import threading
def place():
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)
for i in range(0,15):
x = random.randint(-10,10)
y = random.randint(-10,10)
z = random.randint(-10,10)
bpy.ops.mesh.primitive_uv_sphere_add(location=(x,y,z))
bpy.ops.object.modifier_add(type='SUBSURF')
bpy.context.object.modifiers['Subdivision'].render_levels=0
bpy.context.object.modifiers['Subdivision'].levels=0
timer = threading.Timer(2.0, place)
timer.start()
return None
place()