Python - '3D View Generic' keymap returns inconsistent results depending on how you access the keymap. #69031

Closed
opened 2019-08-22 06:39:16 +02:00 by eldee smith · 3 comments

System Information
Operating system: Windows-10-10.0.18362 64 Bits
Graphics card: GeForce GTX 1050 Ti with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 431.70

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: f6cb5f5449
Worked: (optional)

Short description of error
This is kind of difficult to explain, especially having spent the better part of the past 8 hours zeroing in on this bug but here goes- the 3D View (global) keymap is not reliable when used in the addon keyconfig. Often, a keymap item added to this keymap will simply not show up in the input editor after registration. As an alternative, the 3D View Generic keymap is the go-to solution for addons that need to bind a key in the 3D Viewport globally, but I've noticed some really bizarre behavior that can only really be seen for yourself. After binding some keymap items in the 3D View Generic keymap, I ran the attached script. Both tests should be identical because they both do the exact same thing. In my test, I got different results.

Test script:

import bpy

wm = bpy.context.window_manager
kc = wm.keyconfigs.addon
        
print("Direct check:")
km = kc.keymaps["3D View Generic"]
for kmi in km.keymap_items:
    print(f"{km.name}: {kmi.idname}")
    
    
print("\nVague Search:")
for km in kc.keymaps:
    if km.name == '3D View Generic':
        for kmi in km.keymap_items:
            print(f"{km.name}: {kmi.idname}")

Output:

Direct check:
3D View Generic: wm.call_menu_pie
3D View Generic: view3d.rotate
3D View Generic: view3d.move
3D View Generic: view3d.zoom
3D View Generic: eldee.drop_selection
3D View Generic: eldee.select_objects

Vague Search:
3D View Generic: wm.call_menu_pie
3D View Generic: view3d.rotate
3D View Generic: view3d.move
3D View Generic: view3d.zoom
3D View Generic: eldee.drop_selection
3D View Generic: eldee.select_objects
3D View Generic: eldee.select_verts
3D View Generic: eldee.select_edges
3D View Generic: eldee.select_faces
3D View Generic: eldee.select_objects

**System Information** Operating system: Windows-10-10.0.18362 64 Bits Graphics card: GeForce GTX 1050 Ti with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 431.70 **Blender Version** Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-29 14:47, hash: `f6cb5f5449` Worked: (optional) **Short description of error** This is kind of difficult to explain, especially having spent the better part of the past 8 hours zeroing in on this bug but here goes- the 3D View (global) keymap is not reliable when used in the addon keyconfig. Often, a keymap item added to this keymap will simply *not show up* in the input editor after registration. As an alternative, the 3D View Generic keymap is the go-to solution for addons that need to bind a key in the 3D Viewport globally, but I've noticed some really bizarre behavior that can only really be seen for yourself. After binding some keymap items in the 3D View Generic keymap, I ran the attached script. Both tests should be identical because they both do the exact same thing. In my test, I got different results. Test script: ``` import bpy wm = bpy.context.window_manager kc = wm.keyconfigs.addon print("Direct check:") km = kc.keymaps["3D View Generic"] for kmi in km.keymap_items: print(f"{km.name}: {kmi.idname}") print("\nVague Search:") for km in kc.keymaps: if km.name == '3D View Generic': for kmi in km.keymap_items: print(f"{km.name}: {kmi.idname}") ``` Output: > Direct check: > 3D View Generic: wm.call_menu_pie > 3D View Generic: view3d.rotate > 3D View Generic: view3d.move > 3D View Generic: view3d.zoom > 3D View Generic: eldee.drop_selection > 3D View Generic: eldee.select_objects > Vague Search: > 3D View Generic: wm.call_menu_pie > 3D View Generic: view3d.rotate > 3D View Generic: view3d.move > 3D View Generic: view3d.zoom > 3D View Generic: eldee.drop_selection > 3D View Generic: eldee.select_objects > 3D View Generic: eldee.select_verts > 3D View Generic: eldee.select_edges > 3D View Generic: eldee.select_faces > 3D View Generic: eldee.select_objects > >
Author

Added subscriber: @testure

Added subscriber: @testure
Author

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
eldee smith self-assigned this 2019-08-23 00:02:54 +02:00
Author

Figured it out- the missing keymap items were added to a version of they 3D View Generic keymap that has space_type='EMPTY' rather than 'VIEW_3D'

Figured it out- the missing keymap items were added to a version of they 3D View Generic keymap that has space_type='EMPTY' rather than 'VIEW_3D'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#69031
No description provided.