2
$\begingroup$

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:

contents of 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.

$\endgroup$
2
  • 2
    $\begingroup$ See: poll() failed, context incorrect? $\endgroup$
    – brockmann
    Commented Mar 3, 2020 at 15:30
  • 1
    $\begingroup$ There is no UI in headless mode. This is why area, space_data, region are none. If the operator needs a UI element to poll, then AFAIK there is no way around it. $\endgroup$
    – batFINGER
    Commented Mar 3, 2020 at 16:32

1 Answer 1

1
$\begingroup$

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).

$\endgroup$

You must log in to answer this question.

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