Camera selection in dumb config.py

I know I’m doing this all wrong but please bear with me…

config.py has lines like:

Scenename = 'SCENE_NAME'
bpy.data.scenes[Scenename].render.resolution_x = 1920
bpy.data.scenes[Scenename].render.resolution_y = 1080
bpy.context.scene.render.layers[0].cycles.use_denoising = False

render.sh is a bash shell that does some stuff and ends with:

blender -S "$SCENE" -noaudio -b $FILE.blend -P config_$FILE.py >> $LOGFILE 2>&1

Tonight I find I need to select one of multiple cameras in a single scene (way up from similar scenes with one camera each). This fails:

bpy.data.scenes[Scenename].camera = "Camera2"

TypeError: bpy_struct: item.attr = val: Scene.camera expected a Object type, not str

Looking into it, the error makes sense to me and I think this crude way of rendering in batch might be too limited. Is there any way to select a camera in a simple config.py? If so, how?

Thanks!

you can select cam

obj = bpy.data.scenes[0].objects[‘Camera’]

hope it helps

happy bl

Bingo @RickyBlender

obj = bpy.data.scenes[0].objects['Camnext']
bpy.data.scenes[Scenename].camera = obj

Cheers mate!