blend file which contains multiple camera. Each of this camera will render its own specific frame range. How can i do this without each time have to edit the global frame range ?
-
1$\begingroup$ Possible duplicate of How can I make a camera the active one? $\endgroup$– LeanderApr 6, 2019 at 10:23
-
$\begingroup$ @Leander don't think this is a dupe. Explained as a note on my answer. That said could be that an answer from dupe eg using markers to set active camera is the approach taken by OP. $\endgroup$– batFINGERApr 6, 2019 at 13:28
1 Answer
Property getter and setter.
Quick test script. Wires up a property on the scene, that using uses a get and set method to retrieve data from scene camera if set. The frame start and end properties of the scene are set within the getter.
Ultimately would recommend a corresponding boolean property to turn behaviour off or on. Changing the output folder based on camera. This will avoid overwriting overlapping camera frames.
import bpy
from bpy.props import IntVectorProperty
context = bpy.context
scene = context.scene
'''
# set defaults test code
cam_objs = [c for c in scene.objects if c.type == 'CAMERA']
for c in cam_objs:
c["cam_range"] = [1, 250]
'''
def get_res(self):
if self.camera:
fr = self.camera.get("cam_range", (1, 250))
self.frame_start, self.frame_end = fr
return fr
return (0, 0) # no scene camera
def set_res(self, value):
print("setting", value)
self.camera['cam_range'] = value
bpy.types.Scene.cam_frame_range = IntVectorProperty(
name="Camera Frame Range",
size=2,
get=get_res,
set=set_res,
)
def draw_cam_range(self, context):
scene = context.scene
if scene.camera:
layout = self.layout
'''
if scene.get("cam_range"):
row = layout.row()
row.prop(scene.camera, '["cam_range"]')
'''
row = layout.row()
row.prop(scene, "cam_frame_range")
bpy.types.SCENE_PT_scene.prepend(draw_cam_range)
Note using this method fires off a lot of depsgraph events while displaying the panel.
On the possible duplicate How can I make a camera the active one? the logic here is counter. Setting frame range from active camera as opposed to setting active camera from frame (marker).
-
1$\begingroup$ Cool... thanks a lot. This is what i'm looking for . The script works perfectly ! I think Blender should have this basic feature as an option so i can use global frame range or override by this per camera range. $\endgroup$– andioApr 6, 2019 at 15:50
-
$\begingroup$ It is novel. Re global range, there is the preview range available. (icon button on left of frame start) In hindsight might have been the go to wire this thru preview render, keeping scene frame start / end constant until user set. $\endgroup$ Apr 6, 2019 at 16:25