Using startup folder we can run scripts when Blender starts.
Using this I can change User Preferences and tweak overlay, render and other settings.
But how I can manage to modify keymap?
I believe the only key configurations available at startup are âblender addonâ, and I am not entirely sure as to why. The only potential solution I found could be this https://blender.stackexchange.com/a/131268, though I have not tried it myself. If you do try it, let us know if it works!
It is working tricky, but thatâs what I ended up:
import threading
import time
import bpy
from bpy.app.handlers import load_factory_startup_post, persistent
@persistent
def startup(dummy):
thread = threading.Thread(target=setup_keymap)
thread.start()
def setup_keymap():
kc = bpy.context.window_manager.keyconfigs['blender']
# Here we must wait for all 205 keymaps to be loaded!
while len(kc.keymaps) < 205:
time.sleep(0.01)
# Here you can modify keymap
def register():
load_factory_startup_post.append(startup)
If someone still reading, here is my current code for setup_keymap() part:
def setup_keymap():
kc = bpy.context.window_manager.keyconfigs['blender']
# Here we must wait for all 182 keymaps to be loaded!
while len(kc.keymaps) < 182:
print("Waiting for Keymaps...")
time.sleep(0.01)
# Now you can modify keymap
Hi!
This code is supposed to run when blender starts, so script should be in âstartupâ folder. Also it is better to show off your code so people can say if anything is wrong.