0
$\begingroup$

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
bpy.ops.import_scene.obj(filepath=file_loc)
scene = bpy.context.scene
scene.render.filepath = 'my_render.png'
bpy.ops.render.render("EXEC_DEFAULT", write_still=True)

Thanks

$\endgroup$
1
$\begingroup$

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'
$\endgroup$

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.