Skip to content

Instantly share code, notes, and snippets.

@iCyP
Last active January 18, 2019 14:53
Show Gist options
  • Save iCyP/6480ab8e08e5e7ce8464e49a1302e9be to your computer and use it in GitHub Desktop.
Save iCyP/6480ab8e08e5e7ce8464e49a1302e9be to your computer and use it in GitHub Desktop.
image all reloader for blender2.80
import bpy
bl_info = {
"name":"Image_reloader",
"author": "iCyP",
"version": (0, 1),
"blender": (2, 80, 0),
"location": "ImageEditor->Tools",
"description": "image reloader",
"warning": "",
"support": "TESTING",
"wiki_url": "",
"tracker_url": "",
"category": "Tools"
}
class ICYP_Image_reload_all(bpy.types.Operator):
bl_idname = "image.reload_all"
bl_label = "All image reload"
bl_description = "all image reload"
bl_options = {'REGISTER'}
def execute(self,context):
for img in bpy.data.images:
if img.filepath != "" and not img.is_dirty:
img.reload()
else:
print(f"image {img.name} is not reloaded")
mes = "unsaved image" if img.filepath=="" else "image is edited in blender"
print(f"Because {mes}")
return {"FINISHED"}
class ICYP_PT_Image_reload_all(bpy.types.Panel):
bl_space_type = 'IMAGE_EDITOR'
bl_region_type = "UI"
bl_category = "IMAGE RELOAD"
bl_label = "All image reload"
@classmethod
def poll(cls,context):
return True
@staticmethod
def draw(self,context):
layout = self.layout
layout.operator("image.reload_all")
cls=(
ICYP_Image_reload_all,
ICYP_PT_Image_reload_all
)
def register():
for c in cls:
bpy.utils.register_class(c)
def unregister():
for c in cls:
bpy.utils.unregister_class(c)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment