Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-01-15 08:51:36 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-01-15 08:51:36 +0400
commitaa2e740d6a70785031a7a28c5eb3a8e10c0a34aa (patch)
treeb4918dae31470dce72e11a96011df114fbf8ba45 /object_animrenderbake.py
parent41021075c7cd1893ea431ebb88892fe5c69c5ec7 (diff)
add error for animation baking a packed image.
Diffstat (limited to 'object_animrenderbake.py')
-rw-r--r--object_animrenderbake.py51
1 files changed, 29 insertions, 22 deletions
diff --git a/object_animrenderbake.py b/object_animrenderbake.py
index cefd1cb6..80e48959 100644
--- a/object_animrenderbake.py
+++ b/object_animrenderbake.py
@@ -20,17 +20,17 @@ bl_info = {
"name": "Animated Render Baker",
"author": "Janne Karhu (jahka)",
"version": (1, 0),
- "blender": (2, 58, 0),
+ "blender": (2, 65, 0),
"location": "Properties > Render > Bake Panel",
"description": "Renderbakes a series of frames",
"category": "Object",
- 'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.6/Py/' \
- 'Scripts/Object/Animated_Render_Baker',
- 'tracker_url': 'https://projects.blender.org/tracker/index.php?'\
- 'func=detail&aid=24836'}
+ "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "Scripts/Object/Animated_Render_Baker",
+ "tracker_url": "https://projects.blender.org/tracker/index.php?"
+ "func=detail&aid=24836"}
import bpy
-from bpy.props import *
+from bpy.props import IntProperty
class OBJECT_OT_animrenderbake(bpy.types.Operator):
bl_label = "Animated Render Bake"
@@ -38,15 +38,15 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
bl_idname = "object.anim_bake_image"
bl_register = True
- def framefile(self, orig, frame):
+ def framefile(self, filepath, frame):
"""
Set frame number to file name image.png -> image0013.png
"""
- dot = orig.rfind(".")
- return orig[:dot] + ('%04d' % frame) + orig[dot:]
-
+ import os
+ fn, ext = os.path.splitext(filepath)
+ return "%s%04d%s" % (fn, frame, ext)
+
def invoke(self, context, event):
- import bpy
import shutil
scene = context.scene
@@ -76,11 +76,12 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
img = None
- #find the image that's used for rendering
+ # find the image that's used for rendering
+ # TODO: support multiple images per bake
for uvtex in context.active_object.data.uv_textures:
if uvtex.active_render == True:
for uvdata in uvtex.data:
- if uvdata.image != None:
+ if uvdata.image is not None:
img = uvdata.image
break
@@ -92,12 +93,16 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
self.report({'ERROR'}, "Save the image that's used for baking before use")
return {'CANCELLED'}
+ if img.packed_file is not None:
+ self.report({'ERROR'}, "Can't animation-bake packed file")
+ return {'CANCELLED'}
+
# make sure we have an absolute path so that copying works for sure
img_filepath_abs = bpy.path.abspath(img.filepath, library=img.library)
print("Animated baking for frames (%d - %d)" % (start, end))
- for cfra in range(start, end+1):
+ for cfra in range(start, end + 1):
print("Baking frame %d" % cfra)
# update scene to new frame and bake to template image
@@ -106,7 +111,9 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
if 'CANCELLED' in ret:
return {'CANCELLED'}
- #currently the api doesn't allow img.save_as(), so just save the template image as usual for every frame and copy to a file with frame specific filename
+ # Currently the api doesn't allow img.save_as()
+ # so just save the template image as usual for
+ # every frame and copy to a file with frame specific filename
img.save()
img_filepath_new = self.framefile(img_filepath_abs, cfra)
shutil.copyfile(img_filepath_abs, img_filepath_new)
@@ -116,7 +123,7 @@ class OBJECT_OT_animrenderbake(bpy.types.Operator):
return{'FINISHED'}
-# modified copy of original bake panel draw function
+
def draw(self, context):
layout = self.layout
@@ -133,14 +140,14 @@ def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.animrenderbake_start = IntProperty(
- name="Start",
- description="Start frame of the animated bake",
- default=1)
+ name="Start",
+ description="Start frame of the animated bake",
+ default=1)
bpy.types.Scene.animrenderbake_end = IntProperty(
- name="End",
- description="End frame of the animated bake",
- default=250)
+ name="End",
+ description="End frame of the animated bake",
+ default=250)
bpy.types.RENDER_PT_bake.prepend(draw)