This is the first version of my addon. It uses shift + scroll wheel to change the selection mode in edit mode. There is a slight bug, where on initial activation, it skips edge select if you are either in vert or face mode. Not sure how to fix that. So to use it, simply hold shift and scroll up or down to change modes. This is my first released addon, what do you think? Also, it would be great if anyone can tell me why it it skipping initially.
bl_info = {"name": "Scroll Select",
"author": "Lee Hesketh",
"version": (1, 0),
"blender": (2, 79, 0),
"location": "",
"description": "Change mesh selection mode with the scroll wheel",
"warning": "",
"wiki_url": "",
"category": "Mesh",
}
import bpy
class scrollSelect(bpy.types.Operator):
"""Change Selection mode with scroll wheel"""bl_idname = "mesh.scroll_select"
bl_label = "Scroll Select"
bl_options = { 'REGISTER', 'UNDO' }
@classmethod
def poll(cls, context):
[INDENT=2]return (context.active_object is not None)[/INDENT]
mode = 1
mode_type = [(True, False, False), (False, True, False), (False, False, True)]
def modal(self, context, event):
[INDENT=2]if event.type == 'WHEELUPMOUSE' and self.mode < 2:[/INDENT]
[INDENT=3]self.mode +=1[/INDENT]
[INDENT=2]elif event.type == 'WHEELDOWNMOUSE' and self.mode > 0:[/INDENT]
[INDENT=3]self.mode -=1[/INDENT]
[INDENT=2]context.tool_settings.mesh_select_mode = self.mode_type[self.mode][/INDENT]
[INDENT=2]if not event.shift:[/INDENT]
[INDENT=3]return {'FINISHED'}[/INDENT]
[INDENT=2]return {'RUNNING_MODAL'}
[/INDENT]
def invoke(self, context, event):
[INDENT=2]context.window_manager.modal_handler_add(self)[/INDENT]
[INDENT=2]return {'RUNNING_MODAL'}[/INDENT]
addon_keymaps = []
def register():wm = bpy.context.window_managerkm = wm.keyconfigs.default.keymaps['Mesh']
kmi = km.keymap_items.new(scrollSelect.bl_idname, 'WHEELDOWNMOUSE', 'PRESS', shift=True)
kmj = km.keymap_items.new(scrollSelect.bl_idname, 'WHEELUPMOUSE', 'PRESS', shift=True)
addon_keymaps.append((km, kmi))
addon_keymaps.append((km, kmj))
bpy.utils.register_module(__name__)
def unregister():for km, kmi in addon_keymaps:km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_module(__name__)
if __name__ == "__main__":register()