I keep running into a poll context error for when trying to parent_clear-
File "c:\Users\Willard\Desktop\blender\2.82\scripts\modules\bpy\ops.py", line 199, in __call__
ret = op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)
RuntimeError: Operator bpy.ops.object.parent_clear.poll() failed, context is incorrect
My script works fine and avoids poll errors when running blender with the interface.
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
override = {'area': area, 'region': region, 'edit_object': bpy.context.edit_object}
for s in bpy.context.scene.objects:
if s.type == 'MESH' and s.parent_type == 'OBJECT':
s.select_set(True)
bpy.ops.object.parent_clear(override, type='CLEAR_KEEP_TRANSFORM')
bpy.ops.object.select_all(action='DESELECT')
else:
pass
for o in bpy.context.scene.objects:
if o.type == 'MESH':
o.select_set(False)
else:
o.select_set(True)
bpy.ops.object.delete()
While running the script in background mode I receive the failed context error. I'm not sure how to override that context that I believe is failing because the script is running off the screen