0
$\begingroup$

So I'm trying to do a boolean operation between two objects. Here's how I'm trying to do it.

def engraveText(baseName, textName):
    bpy.ops.object.select_all(action='DESELECT')
    bpy.context.view_layer.objects.active = bpy.context.view_layer.objects[baseName]
    bpy.data.objects[baseName].select_set(True)
    obj = bpy.data.objects[baseName]
    op = obj.modifiers.new(name="bool", type="BOOLEAN")
    op.object = bpy.data.objects[textName]
    op.operation = "DIFFERENCE"
    bpy.ops.object.modifier_apply({"object": obj}, modifier=op.name, apply_as="DATA")

The error I'm getting is :

Traceback (most recent call last):
    File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 2088, in __call__
        return self.wsgi_app(environ, start_response)
    File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 2073, in wsgi_app
        response = self.handle_exception(e)
    File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 2070, in wsgi_app
    File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1515, in full_dispatch_request
        rv = self.handle_user_exception(e)
    File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1513, in full_dispatch_request
        rv = self.dispatch_request()
    File "/usr/local/lib/python3.7/dist-packages/flask/app.py", line 1499, in dispatch_request
        return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
    File "/blender_server/src/server.py", line 76, in getEngravedModel
        engraved_path = be.engraveNewModel(base_path, face_path, text)
    File "/blender_server/src/blender_engraver.py", line 106, in engraveNewModel
        engraveText(base_name, text_name)
    File "/blender_server/src/blender_engraver.py", line 93, in engraveText
        bpy.ops.object.modifier_apply({"object": obj}, modifier=op.name, apply_as="DATA")
    File "/usr/lib/python3.7/2.83/scripts/modules/bpy/ops.py", line 199, in __call__
        ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
RuntimeError: Error: Modifier is disabled, skipping apply

If I'm missing any info please let me know.

$\endgroup$
7
  • $\begingroup$ Quite simply cannot apply a disabled modifier. Far better off using blender.stackexchange.com/questions/146559/… $\endgroup$
    – batFINGER
    Commented Aug 19, 2021 at 13:31
  • $\begingroup$ So I should use bmeshs to apply a boolean modifier? $\endgroup$
    – Euan
    Commented Aug 19, 2021 at 13:52
  • $\begingroup$ Or to_mesh Hard to know, the error message suggests you are using bpy as a python module and running from flask. Can you run the code without applying the modifier and then take a peek in blender? $\endgroup$
    – batFINGER
    Commented Aug 19, 2021 at 14:07
  • $\begingroup$ So after running it in blender directly it seems that the object I'm trying to select isn't a mesh, rather still a text curve. I'm going to try convert it and see what happens. $\endgroup$
    – Euan
    Commented Aug 19, 2021 at 14:57
  • $\begingroup$ So after converting it to a mesh the issue still occurs in the python code I run with flask, but not the one I run directly in blender. Could this be an issue with blender running headlessly? $\endgroup$
    – Euan
    Commented Aug 19, 2021 at 15:26

1 Answer 1

0
$\begingroup$

So it turns out this error was being caused by the fact the blender code was being run in flask.

I found a solution here : https://stackoverflow.com/questions/65685398/bpy-works-in-global-scope-but-not-in-flask-app

$\endgroup$

You must log in to answer this question.

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