Automatic Reload script for the UV/Image Editor

I am thinking of writing a script wich allows to one to let the UV/Image Editor reload an image automatically per 5 secs or something…
I have some expierience in programming with Python, but not really with writing scripts for Blender. So is it possible to write such a script?
If it is: what is the code for just reloading an Image in the UV/Image Editor, where can I find this?

Thanks in advance.

-Fenryal

I added the reload function a while back for this purpose
and used it to pipe screencaptures of the gimp into blender :slight_smile: - got about 5/10 fps.

This should work!- make it a redraw scriptlink.,

  • Hint! For fast updating disable mipmaps in the preferences.
    It means that for every reload, blender dosent have to re-generage a multi-resolution set of images.

import Blender
import os
img= Blender.Image.GetCurrent() # currently displayed picture.
path= Blender.sys.expandpath(img.filename)
if Blender.sys.exists(path):
  t= os.path.getctime(path)
  if t != Blender.my_image_time:
    img.reload()
  Blender.my_image_time= t # global, persists between running the scripts.

Thanks for your reply,

Guess its just my stupid fualt, but when I run this script an error occurs
Console:
http://i44.photobucket.com/albums/f18/Rambob/Console_Message.png

This is what I did:
-I copied your script in the Text window;
-I loaded an image in the UV/Image Editor + I made a cube in the 3D window and textured the texture from the Image Editor on the cube;
-I made a scriptlink and turned it on Redraw;
-I pressed ALT+P in the text window.

So… How do I fix this?

oops… after
import Blender

add


try:
  Blender.my_image_time
except:
  Blender.my_image_time=0

This will initialize my_image_time if its not there.

Thanks for your reply again,
This is how my code looks like:

import Blender
try: 
  Blender.my_image_time 
except: 
  Blender.my_image_time=0 
import os 
img= Blender.Image.GetCurrent() # currently displayed picture. 
path= Blender.sys.expandpath(img.filename) 
if Blender.sys.exists(path): 
  t= os.path.getctime(path) 
  if t != Blender.my_image_time: 
    img.reload() 
  Blender.my_image_time= t # global, persists between running the scripts.

But when I edit the texture in Gimp (after I pressed ALT+P ofcourse), and save it, blender doesn’t reload the texture I just edited (thats what I want to do with the reload script…).

Got it working…
http://en.wikibooks.org/wiki/Blender_3D:_Blending_Into_Python/Cookbook#Monitor_Image
You needed to redraw the image view, also make sure the current image isnt None.

Thanks for your reply.

but it still isnt workling for me :frowning: , what am I doing wrongh?
I just copied the script in Blenders text editor
I loaded an image in the UV/Image Editor + I made a cube in the 3D window and textured the texture from the Image Editor on the cube;
I made a scriptlink and turned it on Redraw;
I pressed ALT+P in the text window. After that I made some changes to the image texture, I saved it…but no changes to the texture in Blender… :frowning: