forked from nortikin/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PolyCamsRender.py
88 lines (63 loc) · 2.62 KB
/
PolyCamsRender.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
import bpy
from bpy_extras.io_utils import ExportHelper
from bpy.props import StringProperty, BoolProperty, EnumProperty
from bpy.types import Operator
bl_info = {
"name": "PolyCams Render",
"author": "Alexander Nedovizin",
"version": (0, 1, 0),
"blender": (2, 6, 7),
"category": "Render"
}
class ExportSomeData(Operator, ExportHelper):
"""This appears in the tooltip of the operator and in the generated docs"""
bl_idname = "export_test.some_data" # important since its how bpy.ops.import_test.some_data is constructed
bl_label = "Export Some Data"
# ExportHelper mixin class uses this
filename_ext = ""
def execute(self, context):
return render_me(self.filepath)
def render_me(filepath):
sceneName = bpy.context.scene.name
for cam in bpy.data.objects:
if ( cam.type =='CAMERA' and not cam.hide_render):
bpy.data.scenes[sceneName].camera = cam
bpy.data.scenes[sceneName].render.filepath = filepath+'\\'+cam.name+'\\cadr_'
bpy.ops.render.render(animation=True)
print('Done!')
print(bpy.data.scenes[sceneName].render.filepath)
return {'FINISHED'}
class RenderMe(bpy.types.Operator):
"""Cams render"""
bl_idname = "scene.render_me"
bl_label = "Render Me"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.export_test.some_data('INVOKE_DEFAULT')
return {'FINISHED'}
def menu_func(self, context):
self.layout.operator(RenderMe.bl_idname)
def menu_func_export(self, context):
self.layout.operator(ExportSomeData.bl_idname, text="Cams Render!")
addon_keymaps = []
def register():
bpy.utils.register_class(RenderMe)
bpy.types.VIEW3D_MT_object.append(menu_func)
bpy.utils.register_class(ExportSomeData)
bpy.types.INFO_MT_file_export.append(menu_func_export)
# handle the keymap
wm = bpy.context.window_manager
km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')
kmi = km.keymap_items.new(RenderMe.bl_idname, 'F12', 'PRESS', ctrl=True, shift=False)
addon_keymaps.append((km, kmi))
def unregister():
bpy.utils.unregister_class(RenderMe)
bpy.types.VIEW3D_MT_object.remove(menu_func)
bpy.utils.unregister_class(ExportSomeData)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
# handle the keymap
for km, kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
if __name__ == "__main__":
register()