bpy.ops.sculpt.brush_stroke Incorrect context when called using the bpy module in headless mode I have been trying to sculpt a mesh using the Python API (v2.83), running via the bpy module in headless mode. So far, I can render the mesh as is, but as soon as I try to use bpy.ops.sculpt.brush_stroke() I get the RunTimeError:


  RuntimeError: Operator bpy.ops.sculpt.brush_stroke.poll() failed, context is incorrect


The following are the contents of my bpy.context:



Note that I have set the mode to "SCULPT", and would like to sculpt the "Body" object. Inspecting the contents of bpy.context.area, it is None. Should it be "3D_VIEW", and how to change it since bpy.context.area is read only? 

Thank you in advance.
bpy.context holds some information about the current windows and open views which is needed by bpy.ops.sculpt.brush_stroke and not available in headless mode. Take a look at this example here to see how to use brush_stroke() without headless mode. If you use Blender on a machine which doesn't have a graphical user interface, you could use a virtual frame buffer (see here).