-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender_selected_frames.py
104 lines (83 loc) · 3.13 KB
/
render_selected_frames.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ##### BEGIN GPL LICENSE BLOCK #####
#
# 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.
#
# 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.
#
# 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.
#
# ##### END GPL LICENSE BLOCK #####
# <pep8-80 compliant>
bl_info = {
"name": "Render Selected Frames",
"author": "Agnieszka Pas",
"version": (1, 1, 0),
"blender": (2, 79, 0),
"location": "Properties > Render",
"warning": "",
"description": "Render Selected Frames",
"category": "Render",
}
import bpy
from bpy.types import Operator
class RenderSelectedFramesOperator(Operator):
"""Render Selected Frames"""
bl_idname = "render.render_frames"
bl_label = "Render Frames"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
scene = context.scene
path = scene.render.filepath
scene.render.image_settings.file_format = 'PNG'
frames_string = scene.NewSelectedFrames
frames_list = []
if frames_string == '':
self.report({'WARNING'}, "Choose frames to render first")
return {'CANCELLED'}
else:
splitted = frames_string.split(',')
for s in splitted:
if s.find('-') > -1:
range_ends = s.split('-')
start = int(range_ends[0])
end = int(range_ends[1])
for num in range(start,end):
frames_list.append(num)
frames_list.append(end)
else:
if s.isdigit():
frames_list.append(int(s))
for frame in frames_list:
scene.frame_set(frame)
scene.render.filepath = path + str(frame)
bpy.ops.render.render(write_still=True)
scene.render.filepath = path
return {'FINISHED'}
def draw_render_frames(self, context):
layout = self.layout
col = layout.column()
row = col.row()
row.label("Selected Frames:")
col.prop(context.scene, "NewSelectedFrames", text="")
col.operator("render.render_frames")
def register():
bpy.types.Scene.NewSelectedFrames = bpy.props.StringProperty(
name="Frames",
default="",
description="Frames to render, for example: 1,3-5,8")
bpy.utils.register_module(__name__)
bpy.types.RENDER_PT_render.append(draw_render_frames)
def unregister():
del bpy.types.Scene.NewSelectedFrames
bpy.types.RENDER_PT_render.remove(draw_render_frames)
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":
register()