I really hope this is an easy question. I literally searched for hours now and I just cannot figure this out. I simplified my (quite extensive) code to these lines that throw the error:
import bpy bpy.ops.object.mode_set(mode = 'OBJECT') obj = bpy.context.selected_objects old_colls = obj.users_collection for coll in old_colls: bpy.data.collections[coll.name].objects.unlink(obj) bpy.data.collections["Final"].objects.link(obj) bpy.context.area.type = 'VIEW_3D' print(bpy.context.area.type) bpy.ops.object.mode_set(mode = 'POSE')
The last line throws:
RuntimeError: Operator bpy.ops.object.mode_set.poll() failed, context is incorrect
mode_set should work in many contexts but I just assured to be in VIEW_3D.
What I also noticed is that, after running the code, I cannot manually change the context mode anymore:
It is greyed out.
When I manually select anything in the scene, I can then properly change the mode again. What is happening here?