Request : can someone create a script for me = snap on ( vertex , edge , face )

i assigned a hotkey for snap type vertex , edge , face
which is ctrl 1 , 2 , 3 , i have separate hotkey for toggle snap on / off
later i find it not productive because there is too many keystroke involve

also i really dont want use ctrl modifier for temporary snap
there is minor annoyance when using it with pen tablet

i was looking for toggle on / off snap + automatically select the type of snap ( one hotkey stroke )
unfortunately there is no function in this blender for this type of workflow

so i am here and want to ask if someone can make a volunteer script for me

what i really want is that combine into one hotkey for toggle snap and type of snap

example scenario

  1. snap magnet is not active
  2. if i hit ctrl 1 snap magnet will automatically on + it will choose vertex snap type
  3. if the snap magnet is on and i press ctrl 1 again the magnet snap will be turn off
    but if i cycle through ctrl 2 3 it will not turn off because snap type element is not the same

i really appreciate if someone can create this kind of script
thank you in advance

Maybe you can use this script https://blenderartists.org/forum/showthread.php?411927-Addon-Re-Last-1-1-0

Hi MatsuikoHiroka.


import bpy
from bpy.props import StringProperty

snap_keymaps = { 'ONE':'VERTEX',
                    'TWO':'EDGE',
                    'THREE':'FACE'}

key_values = [1,2,3]

def main(context, mode):
    tools = context.scene.tool_settings
    if not tools.use_snap:
        tools.use_snap = True
        tools.snap_element = mode
    elif tools.snap_element != mode:
        tools.snap_element = mode
    else:
        tools.use_snap = False

class SnapKeys(bpy.types.Operator):
    """"""
    bl_idname = "object.snap_keys"
    bl_label = "Snap Keys"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None
    
    mode = StringProperty(name='Mode')
    
    def execute(self, context):
        main(context, self.mode)
        return {'FINISHED'}


def register():
    bpy.utils.register_module(__name__)
    wm = bpy.context.window_manager
    deactivate_list = ['ONE', 'TWO', 'THREE']
    view3d_km_items = wm.keyconfigs.default.keymaps['Mesh'].keymap_items
    for j in view3d_km_items:
        if j.type in deactivate_list and j.name == 'Subdivision Set':
            if j.value in key_values:
                j.active = False
                
    km = wm.keyconfigs.default.keymaps['Mesh']
    for k, v in snap_keymaps.items():
        kmi = km.keymap_items.new(SnapKeys.bl_idname, k, 'PRESS', ctrl=True, shift=False)
        kmi.properties.mode = v
 
def unregister():
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()

that was very fast , thank you so much
its working perfectly

Hi again i desperate need help i really cant live without this script , if you got time mind if can you update the script for 2.8 ?