From c9bbc767db9330c8e1b1523d3bee904d432a3c1f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Feb 2025 10:51:05 +1100 Subject: [PATCH 1/2] Docs: correct context.temp_override example Address #134296 --- doc/python_api/examples/bpy.ops.1.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/python_api/examples/bpy.ops.1.py b/doc/python_api/examples/bpy.ops.1.py index 1369e5aad5b..0b39e4e1216 100644 --- a/doc/python_api/examples/bpy.ops.1.py +++ b/doc/python_api/examples/bpy.ops.1.py @@ -6,15 +6,20 @@ It is possible to override context members that the operator sees, so that they act on specified rather than the selected or active data, or to execute an operator in the different part of the user interface. -The context overrides are passed as a dictionary, with keys matching the context -member names in bpy.context. +The context overrides are passed in as keyword arguments, +with keywords matching the context member names in ``bpy.context``. For example to override ``bpy.context.active_object``, -you would pass ``{'active_object': object}`` to :class:`bpy.types.Context.temp_override`. +you would pass ``active_object=object`` to :class:`bpy.types.Context.temp_override`. .. note:: You will nearly always want to use a copy of the actual current context as basis (otherwise, you'll have to find and gather all needed data yourself). + +.. note:: + + Context members are names which Blender uses for data access, + overrides do not extend to overriding methods or any Python specific functionality. """ # Remove all objects in scene rather than the selected ones. From dab47b83a83745874aee25063d1d724f65784da2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Feb 2025 12:09:19 +1100 Subject: [PATCH 2/2] Cleanup: de-duplicate numbered key definition with loop --- .../keyconfig/keymap_data/blender_default.py | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/scripts/presets/keyconfig/keymap_data/blender_default.py b/scripts/presets/keyconfig/keymap_data/blender_default.py index 3a21c488002..8c42b6d6892 100644 --- a/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -2291,33 +2291,16 @@ def km_node_editor(params): {"properties": [("data_path", "space_data.overlay.show_overlays")]}), *_template_items_context_menu("NODE_MT_context_menu", params.context_menu_event), # Viewer shortcuts. - ("node.viewer_shortcut_get", {"type": 'ONE', "value": 'PRESS'}, {"properties": [("viewer_index", 1)]}), - ("node.viewer_shortcut_set", {"type": 'ONE', "value": 'PRESS', - 'ctrl': True}, {"properties": [("viewer_index", 1)]}), - ("node.viewer_shortcut_get", {"type": 'TWO', "value": 'PRESS'}, {"properties": [("viewer_index", 2)]}), - ("node.viewer_shortcut_set", {"type": 'TWO', "value": 'PRESS', - 'ctrl': True}, {"properties": [("viewer_index", 2)]}), - ("node.viewer_shortcut_get", {"type": 'THREE', "value": 'PRESS'}, {"properties": [("viewer_index", 3)]}), - ("node.viewer_shortcut_set", {"type": 'THREE', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 3)]}), - ("node.viewer_shortcut_get", {"type": 'FOUR', "value": 'PRESS'}, {"properties": [("viewer_index", 4)]}), - ("node.viewer_shortcut_set", {"type": 'FOUR', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 4)]}), - ("node.viewer_shortcut_get", {"type": 'FIVE', "value": 'PRESS'}, {"properties": [("viewer_index", 5)]}), - ("node.viewer_shortcut_set", {"type": 'FIVE', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 5)]}), - ("node.viewer_shortcut_get", {"type": 'SIX', "value": 'PRESS'}, {"properties": [("viewer_index", 6)]}), - ("node.viewer_shortcut_set", {"type": 'SIX', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 6)]}), - ("node.viewer_shortcut_get", {"type": 'SEVEN', "value": 'PRESS'}, {"properties": [("viewer_index", 7)]}), - ("node.viewer_shortcut_set", {"type": 'SEVEN', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 7)]}), - ("node.viewer_shortcut_get", {"type": 'EIGHT', "value": 'PRESS'}, {"properties": [("viewer_index", 8)]}), - ("node.viewer_shortcut_set", {"type": 'EIGHT', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 8)]}), - ("node.viewer_shortcut_get", {"type": 'NINE', "value": 'PRESS'}, {"properties": [("viewer_index", 9)]}), - ("node.viewer_shortcut_set", {"type": 'NINE', "value": 'PRESS', 'ctrl': True}, - {"properties": [("viewer_index", 9)]}), + *( + ("node.viewer_shortcut_get", {"type": NUMBERS_0[i], "value": 'PRESS'}, + {"properties": [("viewer_index", i)]}) + for i in range(1, 10) + ), + *( + ("node.viewer_shortcut_set", {"type": NUMBERS_0[i], "value": 'PRESS', "ctrl": True}, + {"properties": [("viewer_index", i)]}) + for i in range(1, 10) + ), ]) return keymap