I am rendering using a python script that renders 5 view angles of an object. So 5 renders, each with a different camera. The code for one of these view angles is:
import bpy
import mathutils
import sys
# Store the current scene inside a variable, that way we can access it later on
scene = bpy.context.scene
# store collection strings
x = bpy.data.collections
y = bpy.data.scenes["CONFIGURATOR 800 x 600"].view_layers["ALL"]
z = bpy.context.view_layer
# render 800 x 600
n = b.name
bpy.context.scene.camera = bpy.context.scene.objects["FMR PAN DOWN"]
bpy.context.scene.cycles.samples = 100
scene.render.resolution_x = 800
scene.render.resolution_y = 600
scene.render.resolution_percentage = 100
scene.render.use_border = False
scene.render.image_settings.file_format = 'PNG'
bpy.data.scenes["CONFIGURATOR 800 x 600"].render.filepath = '/BlenderPythonTest/render_%s 800x600.png' % n
bpy.ops.render.render(write_still = 1)
However! When I run this the scene's camera changed to another random camera upon rendering.
If I comment the rendering out, the active scene camera has, in this case, changed to "FMR PAN DOWN".
I have identified where I have gone wrong but can't seem to fix it. The camera it changes to for rendering is the camera highlighted in the animation panel here:
I have tried to use:
bpy.ops.render.render(write_still = 1, use_viewport=True)
to simulate render image(F12) rather than render animation (Ctrl-f12). But nothing...