0
$\begingroup$

ctrl + alt + Q and ctrl + space are great Shotcuts!

When I maximize the Outliner for example I would prefer a 2.0 or 1.5 resolution scale. Or ingeneral when I maximize a window a changed resolution scale would be handy.

So I am totally new to Python, but I am quite sure setting up a script/addon that quickly does the following should actually be quite simpel:

ctrl +1 = interface resolution scale 1

ctrl +2 = interface resolution scale 1.5

ctrl + 3 = interface resolution scale 2

Or even more advanced:

Or mouse wheel + ctrl + alt + rotating it = 0.5....1...2...5 interface resolution scale "on the fly"

I am also planning on reacording tutorials where changing the interface scale on the fly/quickly would be handy, too.

Could anyone guide me the direction how to accomplish this? I already found parts of the script needed here: Is there a quicker way to change blender UI Resolution Scale?

Actually all I would need to build upon would be a standard script listening for keys so I can add the following command.

    prefs.ui_scale = 1.5 ...

Thanks a lot!

$\endgroup$
1
  • $\begingroup$ Can't help with your question, but be aware that the Ctrl-1,2,3, etc. hotkeys are already in use to add Subdivision Surface modifiers to objects with differing subdivision levels. $\endgroup$
    – John Eason
    Commented Feb 21, 2023 at 22:42

1 Answer 1

2
$\begingroup$

After running the script, go to viewport,
ctrl + mouse_wheel_up: Resolution Scale + 0.1
ctrl + mouse_wheel_down: Resolution Scale - 0.1
(Go to keymap settings, make sure there are no shortcut conflicts)
(Scroll wheel shortcut doesn't work on Outliner, you need to change shortcut if using on Outliner)

import bpy
from bpy.utils import register_class, unregister_class

class SCALE_RES_UP(bpy.types.Operator):
    bl_idname = "view3d.scale_res_up"
    bl_label = "Resolution Scale Up"

    def invoke(self, context, event):
        try:
            bpy.context.preferences.view.ui_scale += 0.1
        except: pass
        return {'FINISHED'}

class SCALE_RES_DN(bpy.types.Operator):
    bl_idname = "view3d.scale_res_dn"
    bl_label = "Resolution Scale Down"

    def invoke(self, context, event):
        try:
            bpy.context.preferences.view.ui_scale -= 0.1
        except: pass
        return {'FINISHED'}

classes = (SCALE_RES_UP, SCALE_RES_DN)
addon_keymaps = []
def register():
    for cls in classes: register_class(cls)

    # Add the hotkey
    wm = bpy.context.window_manager
    kc = wm.keyconfigs.addon
    if kc:
        km = wm.keyconfigs.addon.keymaps.new(name='Screen')
        kmi = km.keymap_items.new("view3d.scale_res_up", type='WHEELUPMOUSE', value='PRESS', ctrl=True)
        addon_keymaps.append((km, kmi))
        kmi = km.keymap_items.new("view3d.scale_res_dn", type='WHEELDOWNMOUSE', value='PRESS', ctrl=True)
        addon_keymaps.append((km, kmi))

def unregister():
    for cls in classes: unregister_class(cls)

    # Remove the hotkey
    for km, kmi in addon_keymaps:
        km.keymap_items.remove(kmi)
    addon_keymaps.clear()

if __name__ == "__main__":
    register()

Example to make a script to add-on: How to duplicate parented objects as one object

$\endgroup$

You must log in to answer this question.

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