diff options
Diffstat (limited to 'release/scripts/modules/bl_previews_utils')
-rw-r--r-- | release/scripts/modules/bl_previews_utils/bl_previews_render.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/release/scripts/modules/bl_previews_utils/bl_previews_render.py b/release/scripts/modules/bl_previews_utils/bl_previews_render.py index 979b47f7a14..51ea53c0eba 100644 --- a/release/scripts/modules/bl_previews_utils/bl_previews_render.py +++ b/release/scripts/modules/bl_previews_utils/bl_previews_render.py @@ -37,6 +37,9 @@ OBJECT_TYPES_RENDER = {'MESH', 'CURVE', 'SURFACE', 'META', 'FONT'} def ids_nolib(bids): return (bid for bid in bids if not bid.library) +def ids_nolib_with_preview(bids): + return (bid for bid in bids if (not bid.library and bid.preview)) + def rna_backup_gen(data, include_props=None, exclude_props=None, root=()): # only writable properties... @@ -313,8 +316,9 @@ def do_previews(do_objects, do_collections, do_scenes, do_data_intern): image = bpy.data.images[render_context.image, None] item = getattr(bpy.data, item_container)[item_name, None] image.reload() - item.preview.image_size = (RENDER_PREVIEW_SIZE, RENDER_PREVIEW_SIZE) - item.preview.image_pixels_float[:] = image.pixels + preview = item.preview_ensure() + preview.image_size = (RENDER_PREVIEW_SIZE, RENDER_PREVIEW_SIZE) + preview.image_pixels_float[:] = image.pixels # And now, main code! do_save = True @@ -451,15 +455,15 @@ def do_clear_previews(do_objects, do_collections, do_scenes, do_data_intern): bpy.ops.wm.previews_clear(id_type={'SHADING'}) if do_objects: - for ob in ids_nolib(bpy.data.objects): + for ob in ids_nolib_with_preview(bpy.data.objects): ob.preview.image_size = (0, 0) if do_collections: - for grp in ids_nolib(bpy.data.collections): + for grp in ids_nolib_with_preview(bpy.data.collections): grp.preview.image_size = (0, 0) if do_scenes: - for scene in ids_nolib(bpy.data.scenes): + for scene in ids_nolib_with_preview(bpy.data.scenes): scene.preview.image_size = (0, 0) print("Saving %s..." % bpy.data.filepath) |