0

Is it possibile to access walk_speed setting of Walk Navigation mode via python API? (I know how to activate the Walk mode by script, but I want to change the walk speed).

igmar
  • 199
  • 1
  • 9

1 Answers1

4

Sure, you can access all settings of WalkNavigation via Preferences. Recommend use the python console to figure out:

>>> C.preferences
<bpy_struct, Preferences at 0x1108d8a28>

>>> C.preferences.inputs.walk_navigation. walk_speed use_gravity walk_speed_factor ...

Demo on how to call bpy.ops.view3d.walk() from a script and set the walk_speed to 23 (default is 2.5) by overriding the context of the operator (the actual area and the region):

Blender 3.2+

import bpy
from bpy import context

walk_nav = context.preferences.inputs.walk_navigation walk_nav.walk_speed = 23

for area in context.screen.areas: if area.type == 'VIEW_3D': with context.temp_override(area=area, region=area.regions[-1]): bpy.ops.view3d.walk('INVOKE_DEFAULT') break

Blender 2.8+

import bpy

C = bpy.context

walk_nav = C.preferences.inputs.walk_navigation walk_nav.walk_speed = 23

for area in C.screen.areas: if area.type == 'VIEW_3D': override = C.copy() override['area'] = area override["region"] = area.regions[-1] bpy.ops.view3d.walk(override, 'INVOKE_DEFAULT') break

Also see: Change Navigation into walk Navigation with scripting

p2or
  • 15,860
  • 10
  • 83
  • 143
brockmann
  • 12,613
  • 4
  • 50
  • 93