I want to render an object with transparent background with blender-python script, but I don't know how to get the transparent background.

My script is:

context = bpy.context
scene = bpy.context.scene
scene.render.filepath = 'my_render.png'
bpy.ops.render.render("EXEC_DEFAULT", write_still=True)



You need to enable the Transparent option that you would normally activate in the Film panel which can be found in the Render tab, if you where using the GUI.

bpy.context.scene.render.film_transparent = True

Also make sure that the file format stores the alpha channel.

bpy.context.scene.render.image_settings.color_mode = 'RGBA'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.