Render specific frames with opengl via python
You have to call Scene.frame_set() instead of setting the property Scene.frame_current:

bpy.context.scene.frame_set(234)


Only frame_set() updates animation data correctly. frame_current is mostly intended for reading access to determine the current frame.



Following example renders frame 0, 230, 99 and writes them to the disk as test_000.png, test_099.png and test_230.png.

import bpy
import os

# format integer with leading zeros
def formatNumbers(number, length):
    return '_%0*d' % (length, number)

# get the scene
scn = bpy.context.scene

# get the output path
output_path = scn.render.filepath

# set filename
filename = "test"

# set render frames
render_frames = [0, 230, 99]

# iterate through render frames
for f in render_frames:
    # set the frame
    scn.frame_set(f)
    # set filepath
    scn.render.filepath = os.path.join(
            output_path,
            filename + formatNumbers(f, 3) + ".jpg",
            )
    # render opengl
    bpy.ops.render.opengl(write_still=True)

# reset internal filepath
bpy.context.scene.render.filepath = output_path


Note: .jpg is only a placeholder and will be overwritten by the settings in the render panel.