-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcamera_manager.py
63 lines (42 loc) · 1.48 KB
/
camera_manager.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
bl_info = {
"name": "Camera Manager",
"category": "3D View",
"location": "View3D > Tool Shelf > Camera Manager",
"description": "Easily switch between different cameras",
"author": "Isaac Weaver"
}
import bpy
class CameraManagerPanel(bpy.types.Panel):
"""UI for managing and switching between cameras."""
bl_idname = "camera_manager"
bl_label = "Camera Manager"
bl_space_type = 'VIEW_3D'
bl_region_type = "TOOLS"
bl_category = 'Tools'
def draw(self, context):
layout = self.layout
layout.label('Camera:')
layout.prop(context.scene, 'active_camera', text='', icon='CAMERA_DATA')
layout.prop(context.scene.camera, 'name', text='') # icon='OBJECT_DATAMODE'
def update(scene, context):
scene.camera = bpy.data.objects[scene.active_camera]
def get_camera_list(scene, context):
"""Return a list of all cameras in the current scene."""
items = []
for obj in scene.objects:
if obj.type == 'CAMERA':
items.append((obj.name, obj.name, ""))
return items
def register():
bpy.utils.register_module(__name__)
bpy.types.Scene.active_camera = bpy.props.EnumProperty(
name='Cameras',
description='All cameras in current scene.',
items=get_camera_list,
update=update
)
def unregister():
bpy.utils.unregister_module(__name__)
del bpy.types.Scene.active_camera
if __name__ == "__main__":
register()