[Bf-extensions-cvs] [0bbd9671] blender2.8: Update for 2.8
florianfelix
noreply at git.blender.org
Tue Oct 9 16:36:58 CEST 2018
Commit: 0bbd967117ea762a6d5ffcc7222543121d036f9e
Author: florianfelix
Date: Tue Oct 9 16:03:11 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBAC0bbd967117ea762a6d5ffcc7222543121d036f9e
Update for 2.8
-Updated for 2.8
-tabs to spaces cleanup
-ui: use subpanel in output panel now
-ui: use header checkbox
-turn off by default
===================================================================
M render_auto_save.py
===================================================================
diff --git a/render_auto_save.py b/render_auto_save.py
index f44bae1c..830abeb1 100644
--- a/render_auto_save.py
+++ b/render_auto_save.py
@@ -1,42 +1,36 @@
-#Simplified BSD License
+# ##### BEGIN GPL LICENSE BLOCK #####
#
-#Copyright (c) 2012, Florian Meyer
-#tstscr at web.de
-#All rights reserved.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
#
-#Redistribution and use in source and binary forms, with or without
-#modification, are permitted provided that the following conditions are met:
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-#1. Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-#ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#################################################################
+# ##### END GPL LICENSE BLOCK #####
+
bl_info = {
"name": "Auto Save Render",
- "author": "tstscr",
- "version": (2, 0),
- "blender": (2, 73, 0),
- "location": "Rendertab -> Render Panel",
+ "author": "tstscr(florianfelix)",
+ "version": (2, 1),
+ "blender": (2, 80, 0),
+ "location": "Rendertab -> Output Panel -> Subpanel",
"description": "Automatically save the image after rendering",
"warning": "",
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Render/Auto_Save",
"tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
"category": "Render"}
-###########################################################################
+
+
import bpy
+from bpy.types import Panel
from bpy.props import BoolProperty, EnumProperty
from bpy.app.handlers import persistent
from os.path import dirname, exists, join
@@ -47,15 +41,18 @@ from re import findall
@persistent
def auto_save_render(scene):
- if not scene.save_after_render or not bpy.data.filepath:
+ if not scene.auto_save_after_render or not bpy.data.filepath:
return
rndr = scene.render
original_format = rndr.image_settings.file_format
format = rndr.image_settings.file_format = scene.auto_save_format
- if format == 'OPEN_EXR_MULTILAYER': extension = '.exr'
- if format == 'JPEG': extension = '.jpg'
- if format == 'PNG': extension = '.png'
+ if format == 'OPEN_EXR_MULTILAYER':
+ extension = '.exr'
+ if format == 'JPEG':
+ extension = '.jpg'
+ if format == 'PNG':
+ extension = '.png'
blendname = basename(bpy.data.filepath).rpartition('.')[0]
filepath = dirname(bpy.data.filepath) + '/auto_saves'
@@ -69,9 +66,9 @@ def auto_save_render(scene):
mkdir(filepath)
#imagefiles starting with the blendname
- files = [f for f in listdir(filepath) \
- if f.startswith(blendname) \
- and f.lower().endswith(('.png', '.jpg', '.jpeg', '.exr'))]
+ files = [f for f in listdir(filepath)
+ if f.startswith(blendname)
+ and f.lower().endswith(('.png', '.jpg', '.jpeg', '.exr'))]
highest = 0
if files:
@@ -82,7 +79,8 @@ def auto_save_render(scene):
if int(suffix[-1]) > highest:
highest = int(suffix[-1])
- save_name = join(filepath, blendname) + '_' + str(highest+1).zfill(3) + extension
+ save_name = join(filepath, blendname) + '_' + \
+ str(highest+1).zfill(3) + extension
image = bpy.data.images['Render Result']
if not image:
@@ -92,56 +90,88 @@ def auto_save_render(scene):
print('Auto_Save:', save_name)
image.save_render(save_name, scene=None)
- if scene.save_blend:
- save_name_blend = join(filepath, blendname) + '_' + str(highest+1).zfill(3) + '.blend'
- print('Blend_Save:',save_name_blend)
- bpy.ops.wm.save_as_mainfile(filepath=save_name_blend, copy=True)
+ if scene.auto_save_blend:
+ save_name_blend = join(filepath, blendname) + '_' + \
+ str(highest+1).zfill(3) + '.blend'
+ print('Blend_Save:', save_name_blend)
+ bpy.ops.wm.save_as_mainfile(filepath=save_name_blend, copy=True)
rndr.image_settings.file_format = original_format
###########################################################################
-def auto_save_UI(self, context):
- layout = self.layout
- split=layout.split()
- col = split.column()
- col.prop(context.scene, 'save_after_render', text='Auto Save Image', toggle=False)
- col.prop(context.scene, 'save_blend', text='with .blend', toggle=False)
- col = split.column()
- col.prop(context.scene, 'auto_save_subfolders', toggle=False)
- col.prop(context.scene, 'auto_save_format', text='as', expand=False)
+class RENDER_PT_render_auto_save(Panel):
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_context = "render"
+ bl_label = "Auto Save Render"
+ bl_parent_id = "RENDER_PT_output"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_OPENGL'}
+
+ @classmethod
+ def poll(cls, context):
+ return (context.engine in cls.COMPAT_ENGINES)
+
+ def draw_header(self, context):
+ rd = context.scene.render
+ self.layout.prop(context.scene, 'auto_save_after_render', text="")
+
+ def draw(self, context):
+ layout = self.layout
+ layout.use_property_split = True
+ layout.use_property_decorate = False # No animation.
+
+ col = layout.column(align=True)
+ col.prop(context.scene, 'auto_save_blend', toggle=False)
+ col.prop(context.scene, 'auto_save_subfolders', toggle=False)
+ col.prop(context.scene, 'auto_save_format', text='as', expand=False)
+
+
+classes = [
+ RENDER_PT_render_auto_save,
+]
+
def register():
- bpy.types.Scene.save_after_render = BoolProperty(
- name='Save after render',
- default=True,
- description='Automatically save rendered images into: //auto_save/')
- bpy.types.Scene.save_blend = BoolProperty(
- name = 'with .blend',
- default=True,
- description='Also save .blend file into: //auto_save/')
+ from bpy.utils import register_class
+ for cls in classes:
+ register_class(cls)
+
+ bpy.types.Scene.auto_save_after_render = BoolProperty(
+ name='Save after render',
+ default=False,
+ description='Automatically save rendered images into: //auto_save/')
+ bpy.types.Scene.auto_save_blend = BoolProperty(
+ name='Save .blend (copy) alongside image',
+ default=False,
+ description='Also save .blend (copy) file into: //auto_save/')
bpy.types.Scene.auto_save_format = EnumProperty(
- name='Auto Save File Format',
- description='File Format for the auto saves.',
- items={
- ('PNG', 'png', 'Save as png'),
- ('JPEG', 'jpg', 'Save as jpg'),
- ('OPEN_EXR_MULTILAYER', 'exr', 'Save as multilayer exr')},
- default='PNG')
+ name='Auto Save File Format',
+ description='File Format for the auto saves.',
+ items={
+ ('PNG', 'png', 'Save as png'),
+ ('JPEG', 'jpg', 'Save as jpg'),
+ ('OPEN_EXR_MULTILAYER', 'exr', 'Save as multilayer exr')},
+ default='PNG')
bpy.types.Scene.auto_save_subfolders = BoolProperty(
- name='subfolder',
- default=False,
- description='Save into individual subfolders per blend name')
+ name='Save into subfolder',
+ default=False,
+ description='Save into individual subfolders per blend name')
bpy.app.handlers.render_post.append(auto_save_render)
- bpy.types.RENDER_PT_render.append(auto_save_UI)
+
def unregister():
- del(bpy.types.Scene.save_after_render)
+ from bpy.utils import unregister_class
+ for cls in reversed(classes):
+ unregister_class(cls)
+
+ del(bpy.types.Scene.auto_save_after_render)
del(bpy.types.Scene.auto_save_format)
del(bpy.types.Scene.auto_save_subfolders)
bpy.app.handlers.render_post.remove(auto_save_render)
- bpy.types.RENDER_PT_render.remove(auto_save_UI)
+
if __name__ == "__main__":
register()
More information about the Bf-extensions-cvs
mailing list