0
$\begingroup$

I googled to see if I can toggle menu items with shortcuts and they explains wm.context_toggle_enum(Context Toggle Values)can do that, but in Blender 3.6 this shortcut setting doesn't work. Is there anyway to do same thing in Blneder 3.6? I need to toggle many things like Transform Operations, Transform Pivot Point, Viewport Shading, Snap Elements ,and so on.

$\endgroup$
6
  • $\begingroup$ Have you seen this in the Blender Python API? docs.blender.org/api/current/… $\endgroup$
    – curious_1
    Commented Aug 26, 2023 at 8:16
  • $\begingroup$ I saw it. I tried some combinations sometimes it works and sometimes it doesn't work. For example wm.context_toggle_enum context attribute= tool_settings.transform_pivot_point value = CURSOR value = INDIVIDUAL_ORIGINS it works but this won't work. I don't know why. wm.context_toggle_enum context attribute = tool_settings.snap_elements value = VERTEX value = EDGE $\endgroup$
    – Yokomizo
    Commented Aug 26, 2023 at 21:08
  • $\begingroup$ FWIW: I wonder if what you just added to your question wouldn't be better posted as an answer to it? It would show more clearly that you found a solution to your problem. $\endgroup$
    – curious_1
    Commented Aug 26, 2023 at 22:07
  • $\begingroup$ choosing my post as an answer to my question? If it is ok I will. $\endgroup$
    – Yokomizo
    Commented Aug 26, 2023 at 23:30
  • $\begingroup$ See this link specifically about answering your own question: blender.stackexchange.com/help/self-answer Just a suggestion, IMHO it might be clearer if you edited your question to cut out the part beginning with "I found out the reason..." and everything following, including the code snippets and paste all that into an answer. Also, if you have the time and haven't seen it before, you might take a look around the Help Center: blender.stackexchange.com/help $\endgroup$
    – curious_1
    Commented Aug 27, 2023 at 5:41

1 Answer 1

1
$\begingroup$

I found out the reason why only snap_elements toggle_enum can't work as keymap in Blender 3.6. When I try this

import bpy
print(bpy.context.scene.tool_settings.snap_elements)
print(bpy.context.scene.tool_settings.transform_pivot_point)

this gives me something like

{'EDGE'}
BOUNDING_BOX_CENTER

tool_settings.transform_pivot_point can toggle transform_pivot_point using wm.context_toggle_enum with values like BOUNDING_BOX_CENTER with CURSOR combination and this can be used as keymap shortcut but tool_settings.snap_elements can't because it needs {''}. Simply values with EDGE and VERTEX won't work anymore. It used to work but Blender developer changed snap_elements enum setting.

I am gonna use this as a custom operator and assign keyboard shortcut instead. I just need to toggle snap elements. I always need to toggle between vertex and edge.

import bpy
current_snap_element = bpy.context.scene.tool_settings.snap_elements
if current_snap_element == {'VERTEX'}:
    bpy.context.scene.tool_settings.snap_elements = {'EDGE'}
elif current_snap_element == {'EDGE'}:
    bpy.context.scene.tool_settings.snap_elements = {'VERTEX'}
else:
    bpy.context.scene.tool_settings.snap_elements = {'VERTEX'}

I thought wm.context_toggle_enum can't be used as keymap anymore but other enum things may work as before. At least tool_settings.snap_elements can't be used as shortcut in Blender 3.6 anymore.

$\endgroup$

You must log in to answer this question.

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