1

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 ?

andio
  • 2,094
  • 6
  • 34
  • 70

1 Answers1

2

Property getter and setter.

enter image description here

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).

batFINGER
  • 84,216
  • 10
  • 108
  • 233
  • 1
    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. – andio Apr 06 '19 at 15:50
  • 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. – batFINGER Apr 06 '19 at 16:25