Inside of the 3D Viewport, there is an option available to perform a 'Viewport Render Animation'. My understanding of this feature is that it performs a full render, using viewport settings across the entire blend file.

Is it possible to invoke this feature directly from the command line? (From either command line arguments or custom python?) I understand it may be possible to look up the individual viewport settings, and set each one in python from the command line, prior to the '-a' argument. But I want the render settings to update as viewport settings change, without updating the render script.

Thanks in advance for all help and consideration.

  • 2
    $\begingroup$ I don't think you can do specifically what you want from the command line. The problem is that the code in Blender that does the "Viewport Render Animation" is simply calling opengl() to make screenshots but command line render doesn't have that option -- it only knows how to render using one of the render engines. You could write a script, of course, because screenshot is now in the API, but I haven't figured that out yet. $\endgroup$ Apr 3, 2022 at 19:30
  • $\begingroup$ Thank you very much for your help! Ever since your first comment, I decided to start looking more deeply into this issue by referencing blender's source code. I was able to find the 'bpy.ops.render.opengl' operator and call it from the console. It did create an image in the 'Rendering' tab, but did not save it to file. If I can find a way to render full animation frames to file, and change viewport settings from python (choose Material Preview Mode, and select overlay options,) then it would completely solve my current issue. $\endgroup$
    – Roobles
    Apr 3, 2022 at 19:44
  • 1
    $\begingroup$ You're welcome. Sorry I didn't understand your problem when I wrote my answer. You probably want bpy.ops.image.save_as() as a starting point to look at. $\endgroup$ Apr 3, 2022 at 19:48

1 Answer 1


I did some investigation, and I may be mistaken, but I don't believe this feature is currently possible in Blender 3.1.2.

It's possible to perform a Viewport Render Animation inside of the python console via:


This will use the context and settings of the viewport in the scripting tab, and will save to the directory defined in Output Properties. However, if you were to run blender from the command line, passing in the following python script:

import bpy

It will come back with the error:

RuntimeError: Error: Cannot use OpenGL render in background mode (no opengl context)

Line 733 of ~/source/blender/editors/render/render_opengl.cc contains

  if (G.background) {
        op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)");
    return false;

Which leads me to believe this is a hard-coded limitation. Blender is checking whether it is simply running in background mode, with no apparent means of instantiating an opengl context and passing it to the opengl operator. (bContext *C is never checked prior to G.background in that method, so it does not matter what is passed.)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .