Python errors on bake: "RuntimeError: Operator bpy.ops.object.convert.poll() failed, context is incorrect"
Hi, I'm trying to run the final bake step on Blender 3.2.2 on Mac OS 12.5.1 (21G83), and I get a console error, the key line seems to be:"
RuntimeError: Operator bpy.ops.object.convert.poll() failed, context is incorrect
Is there something I'm obviously doing wrong? Anything I ought to try next?
Thank you so much, this is an incredible project!
Here is a full error log:
Building lightmaps
Self path: /Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/assets/TLM_Overlay.png
Warning: 1 x Draw window and swap: 15.7161 ms, average: 15.71607590 ms
(3, 2, 2)
No previous material for Material2.002
No Previous material array for: Material2.002
Preparing: UV initiation for object: Material2.002
Traceback (most recent call last):
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/operators/tlm.py", line 52, in invoke
build.prepare_build(self, False)
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/utility/build.py", line 108, in prepare_build
prepare.init(self, previous_settings)
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/utility/cycles/prepare.py", line 24, in init
configure_meshes(self)
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/utility/cycles/prepare.py", line 149, in configure_meshes
bpy.ops.object.convert(target='MESH')
File "/Applications/Blender 3.2.2.app/Contents/Resources/3.2/scripts/modules/bpy/ops.py", line 115, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.convert.poll() failed, context is incorrect
Error: Python: Traceback (most recent call last):
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/operators/tlm.py", line 52, in invoke
build.prepare_build(self, False)
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/utility/build.py", line 108, in prepare_build
prepare.init(self, previous_settings)
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/utility/cycles/prepare.py", line 24, in init
configure_meshes(self)
File "/Users/warren/Library/Application Support/Blender/3.2/scripts/addons/thelightmapper/addon/utility/cycles/prepare.py", line 149, in configure_meshes
bpy.ops.object.convert(target='MESH')
File "/Applications/Blender 3.2.2.app/Contents/Resources/3.2/scripts/modules/bpy/ops.py", line 115, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.convert.poll() failed, context is incorrect
^CTraceback (most recent call last):
File "/Applications/Blender 3.2.2.app/Contents/Resources/3.2/scripts/startup/bl_ui/space_statusbar.py", line 10, in draw
def draw(self, context):
It seems to be failing on this step:
https://github.com/Naxela/The_Lightmapper/blob/85c6532842f53781452f8485257cecf9f4efbe07/addon/utility/cycles/prepare.py#L144-L149
And I am able to bake on a simple model like a cube and plane, as in the wiki example.
I wonder if my model is improperly constructed in some way. It's quite complex, imported from another program:
Any advice on how to work with such models, or to convert them in some way? Cycles is able to render lights within Blender, i just get this error when baking.
Hi, and thanks for using the addon!
That seems strange, although it could be that there's a bug in 3.2+ that I haven't caught. Does it work of you turn off "apply modifiers"? Also, your meshes aren't linked or multi-user by any chance?
Edit: Do you have the option to share the scene?
Thank you for writing back so quickly! Turning off that option didn't help; same result.
https://drive.google.com/file/d/1B7FXu2rZnzIh8rbdBFPkHMSPXKyADfNb/view?usp=sharing
Here is the file -- I tried it in Blender 3.0.1 and it runs without an error, although it seems to have some trouble that I can probably follow tutorials to work through:
Thank you again!
@jywarren Sorry about the late reply. Seems like my github replies went into the spam folder. - I testes the file and I couldn't quite reproduce the bug, but I was wondering if you turn on the verbose option in the settings, does it say anything in more detail when it crashes/produces the bug?:

By default it shouldn't be too much hassle to ligthmap and scene like that one with a bit of uv adjustment and denoising. One thing I did notice was that there's lot of backfacing normals, which means that the light won't reach the surfaces:

Select all the objects and going to Mesh > Normals > Recalculate Outside seems to fix a lot of them:
