I run a background script that:
- deletes everything:
override = {'selected_bases': list(bpy.context.scene.object_bases)}
bpy.ops.object.delete(override)
appends a camera, a mesh and a light as object to the scene from a blend file:
with bpy.data.libraries.load(filepath) as (data_from, data_to): data_to.objects = data_from.objects print ("Objects added for map "+selectedmap+": " +str(data_to.objects))
sets the appended camera for the scene:
bpy.context.scene.camera = bpy.data.objects['Camera']
adds a bunch of cylinders
does a render of the objects in the blend file
saves the file:
bpy.ops.wm.save_mainfile(filepath=basepath + 'FPSPath.blend', check_existing=False)
then repeats again from, delete all
append another camera, mesh and light from a different blend file
render all again, but at this point the new camera does not seem to be selected as active, I do a
bpy.context.scene.camera = bpy.data.objects['Camera']
after appending but, the render keeps coming back empty.
My print debug shows that the camera is changing name, (as camera.001 and so on) could that be the reason I am not getting anything on the render, is there a way to get any camera and then make it the active one?
Also the last blend file saved does not contain the camera, light or mesh objects I appended, should I add something else to the appending method? does it need anything else, the mesh object is never on the render, and only the first camera works.
Thanks.