0
$\begingroup$

I just saw the command object.editmode_toggle () and I am guessing that parenthesis will help invoque a direct selection mode. I´d like to assign a single keypress "U" to do the following: While in object mode, the new keypress will toggle to edit mode and fixes the selection mode to: FACES. How possible is it? Could it just be that I only add an additional shortcut key on the User prefs? Please, help I´d really would like to only press one key and go from object mode to edit mode and have "faces" assigned as the preferred method for selection.

Thanks.Assign a new keyshortcut

$\endgroup$
1
  • $\begingroup$ It's possible, but via Python. $\endgroup$
    – Crantisz
    Commented Jan 26, 2018 at 6:36

1 Answer 1

2
$\begingroup$

To perform two steps from one shortcut, you will need to make your own operator, by putting it into your own addon you can make it active every time you start blender.

Combining two existing steps is simple, you just need to call both existing operators from yours. You can then add a shortcut by using the bl_idname from the operator in the input settings.

To be able to cycle through the selection modes, you look at what the current mode is.

bl_info = {
    "name": "Edit mode with face select", "author": "sambler",
    "version": (1, 0), "blender": (2, 75, 0),
    "location": "blender", "category": "Object",
    "description": "Enter edit mode and set selection type to face.",
    }

import bpy

class EditSelectOperator(bpy.types.Operator):
    bl_idname = 'object.edit_face_select'
    bl_label = 'Enter edit mode and set face selection.'

    def execute(self, context):
        if context.object.mode != 'EDIT':
            # if we aren't in edit mode goto edit and set face select
            bpy.ops.object.mode_set(mode='EDIT', toggle=False)
            bpy.ops.mesh.select_mode(type='FACE')
        else:
            # if we are editing cycle through selection modes
            sel_mode = context.tool_settings.mesh_select_mode
            if sel_mode[0]: # vertex
                bpy.ops.mesh.select_mode(type='EDGE')
            elif sel_mode[1]: # edge
                bpy.ops.mesh.select_mode(type='FACE')
            else: # face
                bpy.ops.mesh.select_mode(type='VERT')
        return {'FINISHED'}


def register():
    bpy.utils.register_class(EditSelectOperator)

def unregister():
    bpy.utils.unregister_class(EditSelectOperator)

if __name__ == "__main__":
    register()
$\endgroup$
7
  • $\begingroup$ Fantastic. Is this possible to do it with the other 2 modes? Vertex selection and Edge Selection? Then All of them 3 be placed on a single operator and toggle them on a single keystroke? for example, I assign face select to keypad "5" then I pressed again, it will toggle to "edge select", then I will press it yet another time, and it will toggle to "vertex" selection? I keep pressing "5", it will return to "face" selection. How would I add those behaviours on the keymap? $\endgroup$ Commented Feb 3, 2018 at 17:33
  • 1
    $\begingroup$ @PierreSchiller adjusted to cycle through select modes. You can setup the one shortcut with the same operator. Just add in into the "3DView (global)" group. $\endgroup$
    – sambler
    Commented Feb 5, 2018 at 22:14
  • $\begingroup$ Great!! This will finally save many hours for all blender users! Thank you very much. $\endgroup$ Commented Feb 6, 2018 at 17:39
  • $\begingroup$ is it possible to press the keybind but then make the object toggle select? Whenever I press the keybind, it changes to facemode but all the faces are selected. What do I change so that the object is selected, I press the keybind, and then it takes me to face mode but not selecting all the faces? I changed toggle=true but is not working. $\endgroup$ Commented Feb 9, 2018 at 3:58
  • $\begingroup$ It should go to edit mode with the previous selection still active, if this is the first time editing then it will select all faces. You can use tab to go to edit mode without changing to face select if you wanted to start with the previous select mode, then use your shortcut to cycle through select modes. You could add bpy.ops.mesh.select_all(action='DESELECT') after the select_mode to deselect everything. $\endgroup$
    – sambler
    Commented Feb 9, 2018 at 13:43

You must log in to answer this question.

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