-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReloadAllImages.py
58 lines (46 loc) · 1.82 KB
/
ReloadAllImages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Coypright (c) 2021 Nidonocu
#
# See LICENCE file for details
bl_info = {
"name": "Reload All Images",
"blender": (2, 93, 0),
"location": "File > Reload Images and Node Editor",
"author": "Nidonocu",
"category": "User Interface",
"description": "Fetch all external image textures referenced within the Blend file, from their last saved disk version",
"version": (1, 0, 0),
"tracker_url": "https://github.com/Nidonocu/ReloadAllImages"
}
import bpy
class ReloadAll(bpy.types.Operator):
"""Fetch all external image textures from their last saved disk version"""
bl_label = "Reload All Images"
bl_icon = "OUTLINER_OB_IMAGE"
bl_idname = "image.reload_all"
bl_description = "Fetch all external image textures from their last saved disk version"
def invoke(self, context, event):
are_files_dirty = False
for image in bpy.data.images:
if (image.is_dirty):
are_files_dirty = True
if (are_files_dirty):
return context.window_manager.invoke_confirm(self, event)
return self.execute(context)
def execute(self, context):
for image in bpy.data.images:
image.reload()
self.report({'INFO'}, "All Textures Reloaded")
return {'FINISHED'}
def menu_draw(self, context):
self.layout.separator()
self.layout.operator("image.reload_all", icon="OUTLINER_OB_IMAGE")
def register():
bpy.utils.register_class(ReloadAll)
bpy.types.TOPBAR_MT_file.append(menu_draw)
bpy.types.NODE_HT_header.append(menu_draw)
def unregister():
bpy.types.TOPBAR_MT_file.remove(menu_draw)
bpy.types.NODE_HT_header.remove(menu_draw)
bpy.utils.unregister_class(ReloadAll)
if __name__ == "__main__":
register()