I'm now trying to change Navigation into walk Navigation in the 3D viewport. So I write the code below.
import bpy
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
for region in area.regions:
if region.type == 'WINDOW':
bpy.ops.view3D.walk()
this returns error
File "D:\3Dmodels\python_demos.blend\operator_modal_view3d.py", line 11, in <module>
File "D:\programs\Blender\stable\blender-2.92.0-windows64\2.92\scripts\modules\bpy\ops.py", line 132, in __call__
ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.view3D.walk.poll() expected a view3d region
So I added a line override = {'area': area, 'region': region}
and change walk()
into walk(override)
.
import bpy
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}
bpy.ops.view3D.walk(override)
However, Blender returns another error
ERROR (wm.operator): C:\b\buildbot-worker-windows\windows_292\blender.git\source\blender\windowmanager\intern\wm_event_system.c:1321 wm_operator_invoke: invalid operator call 'VIEW3D_OT_walk'
So if anyone knows how to run bpy.ops.view3D.walk()
, please teach me and I would be very happy!