I'm trying to get my camera to fit the entire viewport (home
button) in fullscreen mode
and this is what I've come up with so far:
import bpy
context = bpy.context.copy()
for area in bpy.context.window.screen.areas:
if area.type == 'VIEW_3D':
context['area'] = area
bpy.ops.screen.screen_full_area(context, use_hide_panels=True)
area.spaces[0].region_3d.view_perspective = 'CAMERA'
bpy.ops.view3d.view_center_camera({'area': area})
but it keeps giving the error
RuntimeError: Operator bpy.ops.view3d.view_center_camera.poll() failed, context is incorrect
How do I fix this?