1

Scripting in Blender, is it possible to insert an object, wait 1 second, and put a second object? I used the time.sleep(1) (after that the first object has been imported into the scene) but it doesn't work because it put both the objects after 2 seconds. What's the problem??

import time
if x == 3:
    bpy.ops.wm.append(directory= ...., filename= .....)
    time.sleep(1)
elif x == 2:
    bpy.ops.wm.append(directory= ..., filename= .....)
vike
  • 103
  • 3
Valentina
  • 21
  • 1
  • 3

1 Answers1

2

Probably bad idea, but might just work for simple fiddling:

import bpy
import functools

Add 10 cubes in 10 seconds

def add_cubes(x = 0): bpy.ops.mesh.primitive_cube_add(location=(x,x,0)) x += 1 if(x < 10): # Run add_cubes(x) after 1 second bpy.app.timers.register(functools.partial(add_cubes,x), first_interval=1)

add_cubes()

https://docs.blender.org/api/latest/bpy.app.timers.html

Cmazay
  • 306
  • 2
  • 7