8
$\begingroup$

I want to "play" some animation in this UI space, the template_icon_view:

enter image description here

I can load all the images I want, for example:

enter image description here

I know that the gif format is not available.

I know the files with video format (.wmv, .mp4, .avi), can not be played, right?

Then I tested with sprite-sheet, but I can't select or split in each "frame":

enter image description here enter image description here

Then I create operator that allow me change the image, but manually:

actual = wm["my_previews"] 
total =wm["my_previews"] 
contar=True
while contar:
    wm["my_previews"] = wm["my_previews"] +1
    if wm.my_previews == "":
        contar = False
    else:
        total +=1

wm["my_previews"] = wm["my_previews"] 
if avanzar and actual <total:         
    wm["my_previews"] = actual +1            
elif (avanzar and actual == total):
    wm["my_previews"] = 0
elif avanzar==False and actual>0:
    wm["my_previews"] = actual -1
elif (avanzar==False and actual==0):
    wm["my_previews"] =total
       

enter image description here

But I can not do this automatically, because I can not update the template_icon_view and all my tries crash blender.

I try with time, thread:

while Play:
    
    wm["my_previews"] = wm["my_previews"] +1
   
    if wm.my_previews == "":
        wm["my_previews"] =0
        Play = False
    
    time.sleep(0.5)

z = threading.Thread(target=self.testplay(C, self.Play))
if self.Play:
    z.start()
else:
    z.stop()

I checked the Update options in different part of code and nothing works

bpy.context.view_layer.update()
dg =bpy.context.evaluated_depsgraph_get()
dg.update()

Any ideas? Maybe I'm in the wrong UI space to achieve my goal?

Actually, I was thinking of loading some blender files with the animations, but also I can't play that in the template_icon_view.

$\endgroup$
5
  • $\begingroup$ Must it be looped endlessly? $\endgroup$
    – Noob Cat
    Aug 4 '20 at 23:35
  • 1
    $\begingroup$ @NoobCat I thought the same, but the blender interface is frozen until the process is finished $\endgroup$
    – yhoyo
    Aug 5 '20 at 0:33
  • $\begingroup$ You can create a separate thread for it. That is how game engines work. $\endgroup$
    – Bruk
    Aug 9 '20 at 7:05
  • $\begingroup$ I Don't want it for GE @Bruk. Actually do yo have Some code example? $\endgroup$
    – yhoyo
    Aug 9 '20 at 13:22
  • $\begingroup$ @yhoyo I was just saying game engines use that method they calculate physics and other stuff while animating. The reason blender's UI froze is because it have to finish drawing before it can update and since you are running an infinite loop it will never update thus it froze. If you call animate function which update the image and set a timer to call it based upon the frame rate of your animation you can get it working. Here is a link to about timers realpython.com/intro-to-python-threading/#timer. $\endgroup$
    – Bruk
    Aug 12 '20 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.