I have different cameras in the scene. I go through the cameras, change the active camera bpy.context.scene.camera to the camera of my choice and obtain a rendering using Blender Internal rendering engine. This is all done in Python. I set up the scene and the cameras as follow:
import bpy
bpy.ops.import_scene.obj(filepath=objPath)
addLights()
for i in range(numCameras):
addCamera(cameraLocation[i])
rotateCameraToObj() # this rotates the added camera to focus on the mesh
for i in range(numCameras):
switchToCamera(i)
bpy.ops.render.render(write_still=True)
#bpy.ops.render.render(write_still=True) # If uncommented, things would be fine
However, strangely, for one of the cameras (the last one added) I need to do the rendering twice otherwise the first rendering is going to be always black. I made sure nothing is wrong with my camera and other settings that cause getting a black rendering by following the things mentioned here. All settings seem to be fine so I am confused. I also saved the .blend file and loaded it on my computer and were able to obtain renderings with the same camera without any issues. Does anyone know what could be potentially causing the issue? Could it be a bug in Blender?
scene.update()And how could anyone check if they have the issue, without writing their own methods to add and set camera? It would not be difficult to set up a test script to run on default cube would it? – batFINGER Mar 02 '18 at 04:22