0
$\begingroup$

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).

$\endgroup$
1
  • $\begingroup$ Voted to reopen the question. $\endgroup$
    – brockmann
    Commented Jul 19, 2021 at 6:16

1 Answer 1

4
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ Hello! My question was how to access to the walk_speed setting, not how to activate the Walk/Fly Navigation Mode... $\endgroup$
    – igmar
    Commented Jul 19, 2021 at 5:32
  • $\begingroup$ See my edits @igmar $\endgroup$
    – brockmann
    Commented Jul 19, 2021 at 7:37
  • 1
    $\begingroup$ Really great. This approach helps in a lot of different situations! $\endgroup$
    – igmar
    Commented Jul 20, 2021 at 7:30

Not the answer you're looking for? Browse other questions tagged .