1
$\begingroup$

Is there a way to have a separate keymap for orthographic views in Blender 3.6.2? More specifically, I'm using Quad View and I'm trying to remap the middle mouse button for the locked axis views so that it pans instead of rotates. As one of the core functions of that feature is to prevent the ability to rotate, it seems a bit counter intuitive to still have to press Shift+MMB to pan.

For those who use Quad View, do you just swap the keymap for pan and rotate to resolve this? I'm trying not to change too many things from the default (otherwise I feel like I'm handicapping myself to the traditional max/maya layouts).

$\endgroup$

1 Answer 1

0
$\begingroup$

You can create an Operator using bpy.types.Operator which when executed will toggle your 3D View into Quad View and then swap the Shift key function for panning (view3d.move) and rotating (view3d.rotate). All you have to do is copy and paste the following script into the Text Editor under Scripting tab and run it once, and then hover over the 3D Viewport and press F3 and search for "Custom Toggle Quad View". Then instead of clicking it, you should right click it and select Add to Quick Favorites to add it to Quick Favorites. Now you only have to press Q in the 3D Viewport and select this operator to execute it which toggles you in and out of Quad View and automatically swaps the Shift key function for panning and rotating.

enter image description here

Here's the script:

import bpy

class CustomToggleQuadViewOperator(bpy.types.Operator):
    bl_idname = "view3d.custom_toggle_quad_view"
    bl_label = "Custom Toggle Quad View"

    def execute(self, context):
        area = next(area for area in context.window.screen.areas if area.type == 'VIEW_3D')

        with context.temp_override(
            window=context.window,
            area=area,
            region=next(region for region in area.regions if region.type == 'WINDOW'),
            screen=context.window.screen
        ):
            bpy.ops.screen.region_quadview()

        is_quadview = len(area.spaces[0].region_quadviews) == 4

        for km in context.window_manager.keyconfigs.user.keymaps:
            if km.name != '3D View':
                continue
            for kmi in km.keymap_items:
                if kmi.idname == 'view3d.move':
                    kmi.shift_ui = not is_quadview
                elif kmi.idname == 'view3d.rotate':
                    kmi.shift_ui = is_quadview
        
        return {'FINISHED'}

def register():
    bpy.utils.register_class(CustomToggleQuadViewOperator)

def unregister():
    bpy.utils.unregister_class(CustomToggleQuadViewOperator)

if __name__ == "__main__":
    register()

Take note that the keymap items for view3d.move and view3d.rotate are not permanently affected. It is all temporary which will I think suit your needs.

$\endgroup$
2
  • 1
    $\begingroup$ Thank you for the thorough and detailed response! Looking over the script it seems quite useful (glad to know the blender python library is that robust!). I'll give it a go once I'm back in the office(sometime tomorrow), update you on the results, and mark the answer accordingly. $\endgroup$
    – RScoTravis
    Commented Sep 10, 2023 at 22:02
  • 1
    $\begingroup$ Apologies, took longer than I expected to have an opportunity to test this, but It works just fine. I made some adjustments and tested a few other areas of the library (its rather extensive!). Thanks again Harry, such an excellent write-up! $\endgroup$
    – RScoTravis
    Commented Sep 15, 2023 at 20:06

You must log in to answer this question.

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