← Blender.Today
  • 2
  • Published 14 Dec 2019

Blender 2.8x Add-on: Toggle Selection Modes in Edit Mode (Free) -Studio 53 Tools

OnlineRender
14 Dec 2019

3 Comments

good share. just for info you can reduce your exe to a simple line:

bpy.context.tool_settings.mesh_select_mode=(True,True,True)
OnlineRender Author

* @1conscience0dimension * yeah that's ok if I want to select everything, my code cycles the options first then selects (True,True,True)

        cur = [bpy.context.tool_settings.mesh_select_mode[0], bpy.context.tool_settings.mesh_select_mode[1], bpy.context.tool_settings.mesh_select_mode[2]]
        bpy.context.tool_settings.mesh_select_mode = pos[(pos.index(cur)+1)%len(pos)]

* @OnlineRender * sry my bad. I considered that pressing 1234 was toggling. but there is a problem with this. because you can select several mode with shift like vertex and edge and than error. I did a toggle like this in a menu autosmooth menu (to have only one button) but in fact I don't have an error because the else is taking other situations in consideration. it was from a code I found on a forum...

   def execute(self, context):

        selectionMode = (bpy.context.scene.tool_settings.mesh_select_mode)

        if selectionMode[0]:
            bpy.ops.mesh.select_mode('EXEC_DEFAULT', type='EDGE')
        elif selectionMode[1]:
            bpy.ops.mesh.select_mode('EXEC_DEFAULT', type='FACE')
        else:
            bpy.ops.mesh.select_mode('EXEC_DEFAULT', type='VERT')

        return {'FINISHED'}

(in fact the 'EXEC_DEFAULT' is not needed this is the option by default)


1