I've created 3 cameras in my scene and I need to go from the first to the last always in camera view.
What's wrong is that if I start my code in camera perspective, the camera changes and so do the view correctly.
But if i launch my code in user perspective, the cameras will switch correctly but the view not until the end, where it will go in the last camera's perspective
for w in bpy.context.window_manager.windows:
s = w.screen
for a in s:
if a.type = 'VIEW_3D':
for r in a.regions:
if r.type='WINDOW':
override = {'window':w, 'screen':s, 'area':a, 'region':r}
by.ops.view3d.viewnumpad(override, type='CAMERA')
for c in [c for c in bpy.context.scene.objects if c.type == 'CAMERA']:
bpy.context.scene.camera = c
bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations = 1)
Seems like the viewnumpad() is not triggering correctly the view before the switching. How can fix it?
REDRAW_WIN_SWAP
$\endgroup$REDRAW_WIN_swap
$\endgroup$